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...
<h5>Comments</h5>
<% for blogcomment in @blogpost.blogcomments %>
<%= blogcomment.body %>
<hr />
<% end %>
<%= form_tag :action => "comment", :id => @blogpost %>
<%= text_area "comment", "body", :cols => 20, :rows
=> 6 %><br />
<%= 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
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 5, 8:41 pm, RubyonRails_newbie <craigwest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Ah yes - i cleared the tables, started again and the problem has gone!! :-) Thanks for that Frederick! On 6 July, 09:03, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jul 5, 8:41 pm, RubyonRails_newbie <craigwest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.