add message model and migration
This commit is contained in:
parent
a6721fed75
commit
0185ac276c
|
@ -0,0 +1,22 @@
|
|||
ActiveAdmin.register Message do
|
||||
csv do
|
||||
column :title
|
||||
column(:email)
|
||||
column('bODY', humanize_name: false) # preserve case
|
||||
end
|
||||
# See permitted parameters documentation:
|
||||
# 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
|
||||
#
|
||||
permit_params :title, :description, :email, :phone
|
||||
#
|
||||
# or
|
||||
#
|
||||
# permit_params do
|
||||
# permitted = [:title, :description, :email, :phone]
|
||||
# permitted << :other if params[:action] == 'create' && current_user.admin?
|
||||
# permitted
|
||||
# end
|
||||
|
||||
end
|
2
app/models/message.rb
Normal file
2
app/models/message.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class Message < ApplicationRecord
|
||||
end
|
11
db/migrate/20220512140948_create_messages.rb
Normal file
11
db/migrate/20220512140948_create_messages.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class CreateMessages < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :messages do |t|
|
||||
t.string :title
|
||||
t.text :description
|
||||
t.string :email, null: false
|
||||
t.string :phone
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
11
db/schema.rb
11
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_05_12_124755) do
|
||||
ActiveRecord::Schema.define(version: 2022_05_12_140948) do
|
||||
|
||||
create_table "active_admin_comments", force: :cascade do |t|
|
||||
t.string "namespace"
|
||||
|
@ -38,4 +38,13 @@ ActiveRecord::Schema.define(version: 2022_05_12_124755) do
|
|||
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
|
||||
end
|
||||
|
||||
create_table "messages", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.text "description"
|
||||
t.string "email", null: false
|
||||
t.string "phone"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,5 +5,7 @@
|
|||
#
|
||||
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
||||
# Character.create(name: 'Luke', movie: movies.first)
|
||||
AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development?
|
||||
AdminUser.create!(email: 'bijan@example.com', password: '1234567890', password_confirmation: '1234567890') if Rails.env.development?
|
||||
if Rails.env.development?
|
||||
AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password')
|
||||
AdminUser.create!(email: 'bijan@example.com', password: '1234567890', password_confirmation: '1234567890')
|
||||
end
|
||||
|
|
11
test/fixtures/messages.yml
vendored
Normal file
11
test/fixtures/messages.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
7
test/models/message_test.rb
Normal file
7
test/models/message_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class MessageTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue
Block a user