Ruby on Rails Sunday, December 25, 2011



On Mon, Dec 26, 2011 at 7:50 AM, Samir Selman <samir.selman01@gmail.com> wrote:
Try looking into nested forms


On Sun, Dec 25, 2011 at 12:49 PM, Mauro <mrsanna1@gmail.com> wrote:
The models are:

Company
 has_many :categorizations
 has_many :categories, :through => :categorizations

Category
 has_many :categorizations
 has_many :companies, :through => :categorizations

Classification
 has_many :categorizations

Categorization
 belongs_to :company
 belongs_to :category
 belongs_to :classification

I would create a new company, assign a category and assign a
classification to the company.category all with one form.
Is it possible?
I think the only way is to create a new company and assign a category
with one form, then in the company controller or company model assign
a classification at company.category, the classification.id may be
passed as a parameter with the form.
What do you think about?

Yes, it's possible to use 4 models in a single form.  But you have to setup the
naming of the inputs right coupled with accepts_nested_attributes_for.
 

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.



--
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment