Aah wait. One last issue, and it IS the last problem. I can't get it to display the URL right; basically it goes to tutorials/NextTutID and I want it to go to categories/catID/ tutorials/NextTutID
In routes.rb this is the line that makes most things go like this: map.connect 'categories/:id/tutorials/:action', :controller => 'categories' To get it working from this I tried using this link for the link, but it didn't seem to make a difference: <% @NextLesson = Tutorial.next_lesson(@tutorial.position, @tutorial.category_id) %> <%= link_to 'Next lesson', @NextLesson, :controller => 'categories', :id => (@category.id), :action => (@NextLesson) %> When I've used this format before I've used lines like this, but this technique is basically what I've done above, and it just isn't changing.. <%= link_to tutorial.name, :controller => 'categories', :id => (@category), :id => (@category.id), :action => (tutorial.id) %> I think that my routes.rb route URL system is currently bad as it randomly uses the action as the tutorial id etc, but I didn't konw another way to do it so it's setup this way now; Does anyone know how I can change the URL it links to from tutorials/11 (for example) to categories/1/tutorials/11 ? This is my LAST query on this topic and when it's sorted I will have finally finished a new system I'm working on! Thanks for all your help so far guys, Please Help, Thanks In Advance, Joe On May 7, 8:11 pm, Joe <j...@dev-hq.co.uk> wrote: > THANK YOU! > > This was the missing piece of the puzzle, with changing it to :first > and some more editing I've now got it to work! > > If I have any more problems I'll probably create a new topic (unless I > get them very quickly), > > Thanks again, > > Joe > > On May 7, 7:15 pm, Michael Pavling <pavl...@gmail.com> wrote: > > > > > On 7 May 2010 16:28, Joe <j...@dev-hq.co.uk> wrote: > > > > <%= link_to 'Next', Tutorial.next_lesson(@tutorial.id, > > > @tutorial.category_id) %> > > > > Does anyone know why this is happening? > > > I'm only gonna reply this time because you're being so dammed polite. > > But no more from me on this thread... > > > You're putting the result of your class method into the link_to; the > > link_to expects a single AR object, but the method is returning an > > array of them. > > > You could test all this yourself in a console. Run your method and see > > what happens. Then either change the :all to :first, or do something > > else to get a single object (urm... I dunno... like maybe use a plugin > > that does it all for you... I've heard acts_as_list is good ;-) > > > > EXTRA NOTE: By the way I plan to learn more ruby as it is really easy, > > > and is helping my RoR lots. > > > Good for you. It will, given what the first 'R' stands for! > > > -- > > 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 > 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.