ruby on rails - Nested Model Forms -- How do you create an object through an association if it doesn't already exist? -
From Ryan Bates, I get the When I create a new concert and add a whole number of demonstrations, then at the same time, I How does These are my institutions: Rails can handle it for you You need to make sure that you pass correctly in Paramams (which should be done for you in many nested forms) Your concert ,
band and
Exhibit They play I can add performance to a new concert or when I edit a concert when I follow my tutorial, it is quite straightforward and straightforward.
display
band and
display belongs to
related
concerts . In one display, there will be a list of band playback and start / end of time. The band has only one string column for its name.
band objects if they are not already present otherwise the user Has an extra step to make those objects, which will be tedious.
accept _nested_atends / for or some other useful rail facility, can I do this? I am using Rail 2.3.8
class bands & lt; ActiveRecord :: Base has has_many: display has_many: concert ,: through => : End of the Performance Or Class Concert & lt; ActiveRecord :: Base has has_many: Display has_many: band ,: through: = & gt; : Accepts for display_assisted_data_production: display, reject_f = & gt; Lambda {| One | A [: content] .blank? } ,: Allow_destroy = & gt; True end square display & lt; ActiveRecord :: Base is_to: band is_to: concert end
class concert & lt; ActiveRecord :: Base has has_many: Display has_many: band ,: through: = & gt; : Accepts for performance __ nested_attributes_: display end class display & lt; Active Records :: Base official: Concert is_mind: The band accepts_nested_data_apaign: band and class band & lt; ActiveRecord :: Base is_to: performance end
parameter hash should look like this:
{: concert = & gt; ; {: Display_right = & gt; [{: Band_dates = & gt; [{: Name = & gt; "Test u"}] :: name = & gt; "Test p"}] ,: name = & gt; "Test"}}
Comments
Post a Comment