I did try using: "@tutorial.next_lesson" before, however I got this error so figured it must be wrong: undefined method `next_lesson'
I don't quite know why it can't find the method since it's obviously in the model... Has anyone got a solution for this? Thanks In Advance, Joe On May 6, 5:30 pm, Frederick Cheung <frederick.che...@gmail.com> wrote: > On May 6, 5:23 pm, Joe <j...@dev-hq.co.uk> wrote:> When I change it to > "Tutorial.next_lesson" it then says: undefined > > method `nil_class_path' > > > Is this because I have to "pass in the tutorial_id and category_id" or > > is it a different problem? > > You're probably getting nil_class_path because you are returning nil > from somewhere. > You definitely need to pass in the values of tutorial_id - that class > method isn't going to be stealing instance variables out of the > controller or anything like that. > Personally I'd have next_lesson be an instance method of tutorial > > link_to 'Next', @tutorial.next_lesson > > sounds nicer than > > link_to 'Next', Tutorial.next_lesson(@tutorial.id, > @tutorial.category_id) > > or anything like that. > > Fred > > -- > 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-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.