On 6 May 2010 16:41, Joe <j...@dev-hq.co.uk> wrote:
>  def self.next_lesson
>        find :all, :conditions => ["position > ? AND category_id  = ?",
> @tutorial_id, @category_id], :order => 'position', :limit => 1
>        end
>
> and then this code in the link:
>
> <%= link_to 'Next lesson.', @tutorial.next_lesson  %>

using "self" in the method name makes it a class method; so accessible
with "Tutorial.next_lesson". But you'd have to pass in the tutorial_id
and category_id.

Seriously - someone much earlier suggested using acts_as_list. Do. It
deals with all of this for you...

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

Reply via email to