On 6 August 2012 14:29, Steve Morrissey <[email protected]> wrote: > Colin Law wrote in post #1071422: >> On 6 August 2012 14:13, Steve Morrissey <[email protected]> wrote: >>>>> Completed 500 Internal Server Error in 21602ms >>> Thanks for the continued replies, Colin. >>> username: "uberamd", isadmin: nil, isbanned: nil, created_at: >>> comment.created_at. But alas, I am clearly wrong as it doesn't work. >> Where are you getting gravatar_for from? Perhaps you are using a gem >> that is not compatible with your version of rails. >> >> Colin > > I thought about that, but then I tried to do something even easier. A > simple link to the commenters profile <%= link_to comment.user.username, > comment.user %> which gives: > > NoMethodError in Snippets#show > > Showing > /Users/smorriss/ruby_projects/srclockr/app/views/comments/_comment.html.erb > where line #4 raised: > > undefined method `username' for nil:NilClass > Extracted source (around line #4): > > 1: <div class="comment_container"> > 2: <%= comment.inspect %> > 3: <%= comment.user.inspect %> > 4: <span class="username"><%= link_to comment.user.username, > comment.user %> commented <%= time_ago_in_words comment.created_at > %></span> > 5: <div class="comment_content"><%= comment.content %></div> > 6: </div> > > So I'm basically very confused right now. It looks like comment.user has > everything I'd need to do that, yet nothing works. I can't even do a <%= > comment.user.username %> to display the users name, as it fails.
There is something horribly wrong somewhere. Which version of ruby and of rails are you using? rails -v and ruby -v. What do you see for inspect comment.user.username? Colin Law -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

