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? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try looking into nested forms On Sun, Dec 25, 2011 at 12:49 PM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mon, Dec 26, 2011 at 7:50 AM, Samir Selman <samir.selman01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Try looking into nested forms > > > On Sun, Dec 25, 2011 at 12:49 PM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 26 December 2011 03:14, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Mon, Dec 26, 2011 at 7:50 AM, Samir Selman <samir.selman01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> >> Try looking into nested forms >> >> >> On Sun, Dec 25, 2011 at 12:49 PM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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.The problem is that I need to insert a value in the classification_id of the join model Categorization. The table for the join model is automatically enhanced, so when I create a new Company in the categorizations table the attributes company_id and category_id are setted. I want to set also the attribute classification_id of the join table so I think I can do it only in a before_save callback and not in the company form. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Hey, Take a look at fields_for helper. This helper might help you. :D -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 26 December 2011 19:36, Bruno Meira <goesmeira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey, > Take a look at fields_for helper. This helper might help you. > :DSorry for my ignorance, I''m trying but I don''t see the way fields_for can help. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Marco, If I understand your question, Do you want to fill in one form many models. Am I right? If your question is this you can use fields_for to apply it. Check something similar in http://railscasts.com/episodes/73-complex-forms-part-1 :D -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sorry, I made a mistake... Your name is Mauro and not Marco. ;/ -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 December 2011 02:45, Bruno Meira <goesmeira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Marco, > If I understand your question, Do you want to fill in one form many models. > Am I right?Yes but one of the models is the join model of a has_many :through relation. Company has_many :categories, :though => :categorizations Classification has_many :categorizations Categorization belongs_to: company belongs_to: category belongs_to: classification Categorizations attributes are: company_id: integer category_id: integer classification_id: integer amount: decimal When I create a new Company with a category associated a join model categorization is magically created with company_id and category_id setted, ok? I want be able, in the same form, setting also classification_id and amount, so that, when the join model is created, it have company_id, category_id, classification_id and amount all setted Classification_id is taken from a collection: = collection_select :categorization, :classification_id, @classifications, :id, :classification_type Is it possible to do that? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.