i am not grasping a very basic concept here. i have 3 models A, B, C i have a form that is created via controller A but i need to put the data in model B, C so all the input fields belong to either B or C how can i accomplish this so that i can fill the users input if validation does not succeed. using a model A to form A i use @input_info = A.new(params[:a]) but of course this will not work. can someone lead me the right way. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That''s pretty confusing. Could you explain it a little more concretely? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
rushnosh wrote:> i am not grasping a very basic concept here. > > i have 3 models A, B, C > > i have a form that is created via controller A but i need to put the > data in model B, C >ANSWER : NO MATTER, YOU CAN DO IT EXAMPLE : class AController < ApplicationController def create @data = B.new(params[:a]) if @data.save flash[:notice] = " Hello A Form, now you are in B" end end end> so all the input fields belong to either B or C > > how can i accomplish this so that i can fill the users input if > validation does not succeed.For additional attributes that have no existed in table you can use att_reader :new_attribute_name and validation you can put in model/ AR: private def validate if new_attribute_name.nil? errors.add ("Hey new attribute", "you cant be blank.") end end GoodLick :D Reinhart http://teapoci.blogspot.com -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Look into the fields_for helper. It allows you to specify fields for a different model within a form_for block. I''d also suggest looking at railscasts.com, where there''s several screencasts on creating complex forms. Michael Slater www.BuildingWebApps.com (Rails developer portal) www.LearningRails.com (screencasts) On Apr 30, 10:01 am, rushnosh <rashan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i am not grasping a very basic concept here. > > i have 3 models A, B, C > > i have a form that is created via controller A but i need to put the > data in model B, C > > so all the input fields belong to either B or C > > how can i accomplish this so that i can fill the users input if > validation does not succeed. > > using a model A to form A i use @input_info = A.new(params[:a]) but of > course this will not work. > > can someone lead me the right way.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---