ruby - undefined method `strftime' for nil:NilClass [rails 4] -
to break down app quickly: have songs, comments, , users model. user's can upload songs, , make comments.
i seem getting "undefined method `strftime' nil:nilclass" error after submitting (creating) song. if go show#songs.html.erb you'll see comments code below. i've looked how ryan bates comments , code identical. not sure why strftime is't working. please advise :)
note: it's worth i'm running rails 4
full error msg:
nomethoderror in songs#show showing /users/apane/downloads/leap/app/views/songs/show.html.erb line #34 raised: undefined method `strftime' nil:nilclass extracted source (around line #34): <% comment in @song.comments %> <div class="comment"> <strong><%= link_to_unless comment.site_url.blank?, h(comment.author_name), h(comment.site_url) %></strong> <em>on <%= comment.created_at.strftime('%b %d, %y @ %h:%m') %></em> <%=simple_format comment.content %> <p> <% if can? :update, comment %>
the comment.created_at nil
- problem. because have created comment didn't save yet . created_at field filled upon save.
Comments
Post a Comment