TypeError in Classified#show

hELLO…I AM IN DOUBT WITH THIS,…
THANKS

TypeError in Classified#show
Showing app/views/classified/show.rhtml where line #17 raised:

no implicit conversion to float from nil

Extracted source (around line #17):

14:
15: Date Posted: <%=
distance_of_time_in_words_to_now(@classified.created_at) %> ago

16:
17: Last updated: <%=
distance_of_time_in_words(@classified.updated_at, Time.now) %> ago


18:

<%= @classified.description %>


19:
20:

RAILS_ROOT: ./script/…/config/…

Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/views/classified/show.rhtml:17:in

Request
Parameters: {“id”=>“16”}

Show session dump


flash: !map:ActionController::Flash::FlashHash {}

Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}

On 2 November 2011 21:35, Rolando S. [email protected]
wrote:

14:
15: Date Posted: <%=
distance_of_time_in_words_to_now(@classified.created_at) %> ago

16:
17: Last updated: <%=
distance_of_time_in_words(@classified.updated_at, Time.now) %> ago

Well you obviously got past the previous problem with method not
found. I hope you are going to tell us what the problem was. It may
well be relevant to this problem. RoR error messages are often not
that clear but often it is possible to work out what is the problem.
The error says that you cannot convert from nil to a float. That says
that something is nil. Looking at the line of code it seems unlikely
that it is Time.now that is nil so the most likely thing is
@classified.updated_at. That would suggest that you have a record in
the db which has not got a value in the updated_at column.

Colin

#{RAILS_ROOT}/app/views/classified/show.rhtml:17:in

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.


gplus.to/clanlaw

Well this time is another error…
you are right…I check the DB and realize that the field updated_at it
doesn’t take any value itself, once I edit an item on my application.
I’ve edited some items but no items took value at that field, but one
item, ramdonly(I guess),This item is the only one I can show, because
is the unique that take value at this field into the DB…so the others
records don’t take value, that’s why I got that error message

no implicit conversion to float from nil

when I tried to show them.

Why just one record is updated when I edited it…why the others don’t?
Is there any problem with my DB or with the application?
Thanks

I have solved the problem with you have done to me…
thanks…

In had created the DB with all the fields I would use…I didnt add or
drop any of them…but I dont know why…the field update_at doesnt
update…and created_at yes. create_at took value but not updated_at

when I create an item I can upload a picture or not of that item…if I
upload it them updted_at is updated.

Another thing…for instance…I have create an item X.
If i want when I edit it if if I replaced the name by Y por
instance…and save the changes…the DB dont save the updated date at
the field uopdate_at…otherwise if I change the photo/picture or i
replaced the existing one then updated_at took value…a little odd for
me.

Anyway the fact is that I have solve what you suggest me…
Thanks again.

On 3 November 2011 13:01, Rolando S. [email protected]
wrote:

when I tried to show them.

Why just one record is updated when I edited it…why the others don’t?
Is there any problem with my DB or with the application?

I am not sure what you did to fix the previous problem. Did the field
not exist so then you added it? If so then records that were in the
db before you added the field will not have a created_at entry, but
any new ones since then will have the date. I can assure you that
there is a good reason for some having the date and others not, it is
not random, though it may not be clear what the reason is.

For the moment, to stop your view crashing, you could change the code
to something like
<%= distance_of_time_in_words_to_now(@classified.created_at) if
@classified.created_at %>

Colin