Ruby on Rails Saturday, March 31, 2012

Try 

  
  rake routes

 - and you will see, there really isn't defined a student_acounts_path

Try:
resources :students do
  resources :accounts
end


or alternatively in your show (if you want to add a show, edit or update-action in your accounts_controller without an :id param)

form_for [@student, @student.build_account], :url => student_account_path(@student)


best,
B. Pieck


On Sun, Apr 1, 2012 at 3:04 AM, ayesha fernando <lists@ruby-forum.com> wrote:
I keep getting the following error:
NoMethodError in Students#show
undefined method `student_accounts_path' for
#<#Class:0x007ffe2bf6d688>:0x007ffe2c5e5628>

I am trying to implement a has_one model. I followed the rails guide
that used the :post has_many :comments example and tweaked it a bit.

my routes.rb file looks like this:
resources :students do
   resource :account
end

My Students.controller, Account.controller files are attached.
Along with the /app/views/students/show.html.erb file

I have no idea what I'm doing wrong.
Can anyone please help me?

Attachments:
http://www.ruby-forum.com/attachment/7210/students_controller.rb
http://www.ruby-forum.com/attachment/7211/accounts_controller.rb
http://www.ruby-forum.com/attachment/7212/show.html.erb


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


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