Permalink
Please sign in to comment.
Browse files
사용자 필드를 추가하기 위한 expander 모델 추가
설교 게시판에 설교말씀 등 추가적인 사용자 필드를 유동적으로 관리하기 위한 모델
- Loading branch information...
Showing
with
72 additions
and 9 deletions.
- +6 −6 rails/sshb/app/controllers/articles_controller.rb
- +3 −1 rails/sshb/app/models/article.rb
- +3 −0 rails/sshb/app/models/expander.rb
- +8 −1 rails/sshb/app/views/articles/show.html.erb
- +1 −0 rails/sshb/app/views/layouts/_header.html.erb
- +11 −0 rails/sshb/db/migrate/20160118155446_create_expanders.rb
- +12 −1 rails/sshb/db/schema.rb
- +8 −0 rails/sshb/db/seeds.rb
- +13 −0 rails/sshb/test/fixtures/expanders.yml
- +7 −0 rails/sshb/test/models/expander_test.rb
12
rails/sshb/app/controllers/articles_controller.rb
4
rails/sshb/app/models/article.rb
3
rails/sshb/app/models/expander.rb
| @@ -0,0 +1,3 @@ | ||
| +class Expander < ActiveRecord::Base | ||
| + belongs_to :expandable, polymorphic: true | ||
| +end |
9
rails/sshb/app/views/articles/show.html.erb
1
rails/sshb/app/views/layouts/_header.html.erb
11
rails/sshb/db/migrate/20160118155446_create_expanders.rb
| @@ -0,0 +1,11 @@ | ||
| +class CreateExpanders < ActiveRecord::Migration | ||
| + def change | ||
| + create_table :expanders do |t| | ||
| + t.string :name | ||
| + t.string :value | ||
| + t.references :expandable, polymorphic: true, index: true | ||
| + | ||
| + t.timestamps null: false | ||
| + end | ||
| + end | ||
| +end |
13
rails/sshb/db/schema.rb
8
rails/sshb/db/seeds.rb
13
rails/sshb/test/fixtures/expanders.yml
| @@ -0,0 +1,13 @@ | ||
| +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
| + | ||
| +one: | ||
| + name: MyString | ||
| + value: MyString | ||
| + expandable_id: | ||
| + expandable_type: Expandable | ||
| + | ||
| +two: | ||
| + name: MyString | ||
| + value: MyString | ||
| + expandable_id: | ||
| + expandable_type: Expandable |
7
rails/sshb/test/models/expander_test.rb
| @@ -0,0 +1,7 @@ | ||
| +require 'test_helper' | ||
| + | ||
| +class ExpanderTest < ActiveSupport::TestCase | ||
| + # test "the truth" do | ||
| + # assert true | ||
| + # end | ||
| +end |
0 comments on commit
874f180