On Mon, Apr 19, 2010 at 5:48 AM, Eric B. <[email protected]> wrote:
> I am new to both ruby and rails and a recent project I am trying has got
> me working on it. I am trying to find a nice easy lightweight way to
> find the last 'id' in a mysql database so I can take it and use it as
> the upper bound in a random number generator.

You can call a find on your model, assuming you just want the highest id
from that table:

last_id = MyModel.find(:first, :order => 'id desc').id

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to