# No implicit conversion to float from nil

**URL:** <https://www.ruby-forum.com/t/no-implicit-conversion-to-float-from-nil/191115>\
**Category:** Rails\
**Created:** [July 5, 2010, 9:43pm UTC](https://www.ruby-forum.com/t/no-implicit-conversion-to-float-from-nil/191115 "2010-07-05T21:43:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [July 5, 2010, 9:43pm UTC](https://www.ruby-forum.com/t/no-implicit-conversion-to-float-from-nil/191115/1 "2010-07-05T21:43:25Z")

</div>

Good Evening all!!

I am writing a blog into my app at the moment and have got it so that  
users can comment on a post.

THe comments render perfectly, so to enhance the experience, I wanted  
to add a note to show users how long ago a post was added.

Here’s what I have…

##### Comments

\<% for blogcomment in @blogpost.blogcomments %\>  
\<%= blogcomment.body %\>

```
  <hr />

```

\<% end %\>

\<%= form\_tag :action =\> “comment”, :id =\> @blogpost %\>  
\<%= text\_area “comment”, “body”, :cols =\> 20, :rows =\> 6 %\>  
  
\<%= submit\_tag “Comment” %\>

This shows the comment, but when I add the following I get an error:  
(no implicit conversion to float from nil)

(posted on \<%= time\_ago\_in\_words(blogcomment.created\_at) %\>)

I know the table name is correct because the follwing did render the  
date:

(posted on \<%= blogcomment.created\_at %\>)

Ideally I’d like it shown in words instead of a dd/mm/yyyy format.

ANy suggestions??

Thanks

---

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [July 6, 2010, 10:04am UTC](https://www.ruby-forum.com/t/no-implicit-conversion-to-float-from-nil/191115/2 "2010-07-06T10:04:32Z")

</div>

On Jul 5, 8:41 pm, RubyonRails\_newbie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This shows the comment, but when I add the following I get an error:  
> (no implicit conversion to float from nil)
> 
> (posted on \<%= time\_ago\_in\_words(blogcomment.created\_at) %\>)
> 
> I know the table name is correct because the follwing did render the  
> date:

sounds like there is at least one of your blog comments for which  
created\_at is nil

Fred

---

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [July 7, 2010, 9:52pm UTC](https://www.ruby-forum.com/t/no-implicit-conversion-to-float-from-nil/191115/3 "2010-07-07T21:52:06Z")

</div>

Ah yes - i cleared the tables, started again and the problem has  
gone!! 🙂

Thanks for that Frederick!
