Ruby on Rails Friday, July 30, 2010

Model.last



On Fri, Jul 30, 2010 at 10:48 AM, crashbangboom <crashbangboom@gmail.com> wrote:
I'm new to rails and am trying to get an understanding on some of the
language usage...I have a mysql database with a table of data...I want
to retrieve the last record in that table without sending it an 'id'
or anything...I've tried the following:

def get_last_net_vol
      @prevticket = Tankticket.find(:last)
     last_net_vol = @prevticket.net_vol
     return last_net_vol
end

This fails with:

Couldn't find Tankticket with ID=last

Extracted source (around line #54):

51:     <p>VCF = <%= ctl -%></p>
52:     <p>Net Vol = <%= round((grs_vol * ctl + roof_cor), 2) -%></p>
53:
54:     <p>Last Net Vol = <%= get_last_net_vol -%></p>

Everything I've read tells me this should have worked so I'm
suspicious that it might be the version of rails I'm running...!

I'm running an old dual proc mac G4 with os x 10.5.8...ruby version
1.8.6...gem version 1.0.1...rails version 1.2.6

I know I should update to the later version of rails and gem...I have
tried but the standard methods to do so fail with
(Gem:RemoteSourceException) HTTP Response 301 fetching
http://gems.rubyforge.org/yaml)...I guess I could install it the hard
way but I don't want to chance compromising my current running
install...!

Any light shed will be greatly appreciated...!

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

No comments:

Post a Comment