forked from railsadminteam/rails_admin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nested model's field gets ignored when inverse_of name matches with n…
…ested_in field. Closes railsadminteam#1255
- Loading branch information
Showing
7 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class AnotherFieldTest < ActiveRecord::Base | ||
has_many :nested_field_tests, :inverse_of => :another_field_test | ||
attr_accessible :nested_field_test_ids | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
class NestedFieldTest < ActiveRecord::Base | ||
attr_accessible :title, :field_test_id, :comment_attributes | ||
attr_accessible :title, :field_test_id, :another_field_test_id, :comment_attributes | ||
|
||
belongs_to :field_test, :inverse_of => :nested_field_tests | ||
belongs_to :another_field_test, :inverse_of => :nested_field_tests | ||
has_one :comment, :as => :commentable | ||
accepts_nested_attributes_for :comment, :allow_destroy => true, :reject_if => proc { |attributes| attributes["content"].blank? } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AnotherFieldTest | ||
include Mongoid::Document | ||
|
||
has_many :nested_field_tests, :inverse_of => :another_field_test | ||
attr_accessible :nested_field_test_ids | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
spec/dummy_app/db/migrate/20120720075608_create_another_field_tests.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class CreateAnotherFieldTests < ActiveRecord::Migration | ||
def change | ||
create_table :another_field_tests do |t| | ||
t.timestamps | ||
end | ||
add_column :nested_field_tests, :another_field_test_id, :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters