Ruby on Rails Sunday, April 1, 2012

Thanks for your tips Bente,

I ran rake routes, and this is what I got:
student_account POST /students/:student_id/account(.:format)
accounts#create

I thought my routes.rb file HAD to be like this:
resources :students do
resource :account
end

because my Student model only 'has_one' Account (not a has_many)

I changed my form_for to:
form_for ([@student, @student.build_account], :url =>
student_account_path(@student))

And I am no longer getting the 'NoMethodError' BUT the account
information is not being saved to the accounts table.

What key concept am I not understanding?

--
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@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