save each page form values as session variables and only perform the insert to multiple tables on the final page, right?
On Tue, Jul 12, 2011 at 8:32 AM, Rodrigo Ruiz <[email protected]>wrote: > And no, it doesn't work =/ > > > On Tue, Jul 12, 2011 at 12:15 PM, Colin Law <[email protected]>wrote: > >> On 12 July 2011 15:54, Rodrigo Ruiz <[email protected]> wrote: >> >> Could you not top post please, it makes it difficult to follow the >> thread. Insert your comments at appropriate points in previous >> message. Thanks. >> >> > If I do the same as the 196 episode it works, but I want a has_one and >> > belongs_to relationship, no has_many. >> > With has_one it doesn't work. If I set all to singular form (the names >> of >> > model I mean) I get this error: >> > >> > NoMethodError in CompaniesController#new >> > >> > undefined method `build' for nil:NilClass >> > >> > I got company and company_contact models >> > Company model: >> > has_one :company_contact, :dependent => :destroy >> > accepts_nested_attributes_for :company_contact >> > CompaniesController: >> > def new >> > @company = Company.new >> > @company.company_contact.build >> >> I have not done this but looking at the docs [1], for a has_one >> relationship I think you need to do >> @company.build_company_contact >> >> Colin >> >> [1] >> http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html >> >> > end >> > CompanyContact model: >> > belongs_to :company >> > views/companies/new: >> > <% f.fields_for :company_contact do |company_contact_form| %> >> > <div class='field'> >> > <%= company_contact_form.label 'Nome do responsável por Marketing' %> >> > <%= company_contact_form.text_field :marketing_name %> >> > </div> >> > <% end %> >> > >> > >> > On Tue, Jul 12, 2011 at 10:15 AM, Colin Law <[email protected]> >> wrote: >> >> >> >> On 12 July 2011 05:13, Rodrigo Ruiz <[email protected]> wrote: >> >> > It uses a method called 'build', which says (to me at least) that it >> >> > doesn't >> >> > exist. >> >> >> >> Show us the exact error and the code around the failing line. >> >> >> >> Colin >> >> >> >> > >> >> > On Mon, Jul 11, 2011 at 10:15 PM, Everaldo Gomes >> >> > <[email protected]> >> >> > wrote: >> >> >> >> >> >> Take a look in these screencasts: >> >> >> http://railscasts.com/episodes?utf8=%E2%9C%93&search=model >> >> >> http://railscasts.com/episodes/196-nested-model-form-part-1 >> >> >> http://railscasts.com/episodes/197-nested-model-form-part-2 >> >> >> Maybe they can help you. >> >> >> Best regards, >> >> >> Everaldo >> >> >> >> >> >> On Mon, Jul 11, 2011 at 10:11 PM, Hassan Schroeder >> >> >> <[email protected]> wrote: >> >> >>> >> >> >>> On Mon, Jul 11, 2011 at 5:55 PM, Rodrigo Ruiz >> >> >>> <[email protected]> >> >> >>> wrote: >> >> >>> > Problem is I want more than one model as I explained before. >> >> >>> >> >> >>> So each "step" is a different page, different model -- again, what >> is >> >> >>> the issue? Complete one, go to the next. >> >> >>> >> >> >>> -- >> >> >>> Hassan Schroeder ------------------------ >> [email protected] >> >> >>> http://about.me/hassanschroeder >> >> >>> twitter: @hassan >> >> >>> >> >> >>> -- >> >> >>> 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. >> >> >>> >> >> >> >> >> >> -- >> >> >> 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. >> >> > >> >> > -- >> >> > 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. >> >> > >> >> >> >> -- >> >> 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. >> >> >> > >> > -- >> > 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. >> > >> >> -- >> 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. >> >> > -- > 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. > -- 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.

