[Rails] Re: Collection has next question

Jean-François jf.web3 at gmail.com
Wed Apr 12 12:08:29 GMT 2006


Hello John,

> All i need to know is how return the contents of 1 field from an sql
> statement on the posts table.
>
> //This is a variable that i want the id of the next post to put into
> nextid = Post.find(:select => "id",
>             :conditions => "id < 19",
>             :order => 'id ASC LIMIT 1')
>
>
> This si the next post i want to find passing in the id from above.
> @nextpost = Post.find(params[nextid])
>
> Any Examples, i cant find anything on the net?

you may find Jonathan Viney's plugin interesting :

acts_as_ordered :
http://svn.viney.net.nz/things/rails/plugins/acts_as_ordered/README

http://svn.viney.net.nz/things/rails/plugins/acts_as_ordered/

Regards,

    -- Jean-François.

--
Railsfrance - http://www.railsfrance.org


More information about the Rails mailing list