Colin Law wrote in post #1071427:
> On 6 August 2012 14:29, Steve Morrissey <[email protected]> wrote:
>>
>> undefined method `username' for nil:NilClass
>>
>> 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

It's starting to feel good that maybe, just maybe, I'm not losing my 
mind here.

$ rails -v
Rails 3.2.6
$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

undefined method `username' for nil:NilClass
Extracted source (around line #4):

1: <div class="comment_container">
2:   <%= comment.inspect %>
3:   <%= comment.user.inspect %>
4:   <%= comment.user.username.inspect %>
5:   <div class="comment_content"><%= comment.content %></div>
6: </div>

-- 
Posted via http://www.ruby-forum.com/.

-- 
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.


Reply via email to