i am trying to create a helper method to display different time formats if a post was created in the last 24hrs.
This is what I did in the posts_helper.rb
def recent_post_time
@post = Post.find(params[:id])
if @post.created_at.hour < 24
@post.created_at = @post.created_at.strftime("%R")
else
@post.created_at = @post.created_at.strftime("%v")
end
end
And Index view
<% @posts.each do |post| %>
<%= recent_post_timre %>
<% end %>
However I keep getting this error "Couldn't find Post without an ID" any ideas ?