Compare commits
5 Commits
01e10d4936
...
0797f9798d
Author | SHA1 | Date | |
---|---|---|---|
|
0797f9798d | ||
|
31e8e4ac84 | ||
|
3025c88ef7 | ||
|
c771455197 | ||
|
07fcd5fe86 |
2
Gemfile
2
Gemfile
|
@ -29,6 +29,8 @@ gem 'jbuilder', '~> 2.7'
|
||||||
gem 'bootsnap', '>= 1.4.2', require: false
|
gem 'bootsnap', '>= 1.4.2', require: false
|
||||||
gem 'rails_12factor', group: :production
|
gem 'rails_12factor', group: :production
|
||||||
|
|
||||||
|
gem 'rack-cors'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
||||||
|
|
|
@ -155,6 +155,8 @@ GEM
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
racc (1.6.0)
|
racc (1.6.0)
|
||||||
rack (2.2.3)
|
rack (2.2.3)
|
||||||
|
rack-cors (1.1.1)
|
||||||
|
rack (>= 2.0.0)
|
||||||
rack-proxy (0.7.2)
|
rack-proxy (0.7.2)
|
||||||
rack
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
|
@ -275,6 +277,7 @@ DEPENDENCIES
|
||||||
jbuilder (~> 2.7)
|
jbuilder (~> 2.7)
|
||||||
listen (~> 3.2)
|
listen (~> 3.2)
|
||||||
puma (~> 4.1)
|
puma (~> 4.1)
|
||||||
|
rack-cors
|
||||||
rails (~> 6.0.5)
|
rails (~> 6.0.5)
|
||||||
rails_12factor
|
rails_12factor
|
||||||
sass-rails (>= 6)
|
sass-rails (>= 6)
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
ActiveAdmin.register Message do
|
ActiveAdmin.register Message do
|
||||||
csv do
|
csv do
|
||||||
column :title
|
column :title
|
||||||
|
column(:name)
|
||||||
column(:email)
|
column(:email)
|
||||||
column(:phone)
|
column(:phone)
|
||||||
column(:description)# preserve case
|
column(:description)
|
||||||
|
# preserve case
|
||||||
end
|
end
|
||||||
# See permitted parameters documentation:
|
# See permitted parameters documentation:
|
||||||
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
||||||
#
|
#
|
||||||
# Uncomment all parameters which should be permitted for assignment
|
# Uncomment all parameters which should be permitted for assignment
|
||||||
#
|
#
|
||||||
permit_params :title, :description, :email, :phone
|
permit_params :title, :name, :description, :email, :phone
|
||||||
#
|
#
|
||||||
# or
|
# or
|
||||||
#
|
#
|
||||||
|
|
|
@ -4,10 +4,11 @@ class MessagesController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@message = Message.create(message_params)
|
@message = Message.create(message_params)
|
||||||
|
render json: {}, status: :created
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def message_params
|
def message_params
|
||||||
params.permit(:title, :phone, :description, :email)
|
params.permit(:title, :phone, :description, :email, :name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
7
config/initializers/cors.rb
Normal file
7
config/initializers/cors.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
||||||
|
allow do
|
||||||
|
origins '*'
|
||||||
|
resource '*', :headers => :any, :methods => [:get, :post, :options]
|
||||||
|
end
|
||||||
|
end
|
5
db/migrate/20220525092424_add_name_to_message.rb
Normal file
5
db/migrate/20220525092424_add_name_to_message.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddNameToMessage < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :messages, :name, :string
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user