[Rails] Re: Re: Re: Re: Re: Simple (I'm sure) Question about Joins
Colin Law wrote in post #1071422:
> On 6 August 2012 14:13, Steve Morrissey <lists@ruby-forum.com> 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.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home