ruby on rails - render ActiveRecord response in from Controller to View -


i'm new rails. i'm using rails 3.2.13. i'll try keep question succinct:

in controller, want last 10 entries observation table. have:

def index    @times = observation.select(:load_time).last(10) end 

in view, attempt render 10 entries in @times this:

<% @times.each |time| %> <p>time: <%= time %></p> <% end %> 

a response in web page looks this:

time: #<observation:0x007fe22bf2a138> 

i'm wondering how actual time variable float rather (what looks like) memory address. appears last 10 entries correctly making controller good.

there no logic in observation < activerecord::base class because migration responsible defining schema. here's db/migrate/create_observations.rb looks like:

class createobservations < activerecord::migration   def change     create_table :observations |t|         t.float :load_time         t.timestamps             end 

thanks in advance - it's appreciated.

you have access variable inside object

<%= time.your_field %> 

in case:

<%= time.load_time %> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -