On Mon, Mar 1, 2010 at 12:29 PM, Ichiro Saga <[email protected]> wrote:
> Hi, guys. > There are four models in the program, A has_many B through C, B has_many > A through C, A has_many D, D belongs_to A. I have a form to create A. > Inspired by Ryan Bates' railscasts I was able to create A and D in the > same form, and link A to B(created beforehand) through C in the same > form as well. Is it possible to create A and B in the same form? > Thanks in advance. > Ichiro, it might have been better to provide the sample code as follows: class A < AR has_many :B, :through => :C has_many :D end class B < AR has_many :A, :through => :C end class D < AR belongs_to :A end Next, you should be able to create A and B in the same form using accepts_nested_attributes_for. For example, class A < AR has_many :B, :through => :C has_many :D accepts_nested_attributes_for :B end Note: You'll need to create the appropriate form as Ryan Bates walks you through in his nested model form screencasts. Good luck, -Conrad -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

