map.profile is a named route, so it''ll give you the route
"profile_path"
- I''m not 100% sure which would work, but I''d try:
profile_path(comment.user)
or
profile_path(comment.user.screen_name)
> You have a nil object when you didn''t expect it!
> The error occurred while evaluating nil.screen_name
When is this error appearing? When you load the page that contains that
link, or when you follow that link? If it''s the former, check to make
sure that the user and comment models are associated (has_many, has_one,
belongs_to...). If it''s the latter, then we''d need more
information,
like what''s in the "show" action of the profile controller.
Sean Six wrote:> So I have a blog like setup for my website. Users can comment on
> another person''s blog. I want the comment to include a link to
the
> author''s profile. This is proving to be problematic.
>
> The blog is a resource and the comments are also a resource, nested in
> the blog.
> The profile route is this: map.profile
''profile/:screen_name'',
> :controller => ''profile'', :action =>
''show''
>
> So if I have a profile by user Steve, it should link to /profile/steve
> If Steve leaves a comment on a blog, I want to link to his profile. I
> have tried something like <%= link_to comment.user.screen_name,
> profile_for(comment.user) %> and variations of it with no success.
>
> You have a nil object when you didn''t expect it!
> The error occurred while evaluating nil.screen_name
--
Posted via http://www.ruby-forum.com/.