If I am in the controller for Model X, and inside a method there I want to create a new instance of (i.e. insert a new row into the DB table for) Model Y, how do I express this? Thanks, R.Vince -- 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=.
Y.new controllers don''t care what models you use. -eric On Nov 21, 12:09 pm, RVince <rvinc...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> If I am in the controller for Model X, and inside a method there I > want to create a new instance of (i.e. insert a new row into the DB > table for) Model Y, how do I express this? Thanks, R.Vince-- 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=.
Like Eric said. Y.new Y.attribute1 = attribute1value Y.attribute2 = attribute2value Y.save ..etc Or Y.new(params[:y]) Y.save One controller can manage multiple models, and one model can be managed by multiple controllers. I frequently set up additional Restful controllers to manage single attribute changes within a model, even though another controller manages other parts of the model. -- 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=.