I''m trying to use the new RESTful style of development, but am running
into a problem.
I''m trying to show a list of comments, each of which belongs to a user.
And have a link to the user''s page at the bottom of each comment.
In the routes, there is "map.resources :users". The problem is when
using a link_to within a for loop. I don''t know what to pass to
users_url.
1. I''ve tried users_url(comment.user.id), users_url(comment.user), and
a
few other things like that, but that gives the error of "You have a nil
object when you didn''t expect it! The error occurred while evaluating
nil.to_sym".
2. So next, i tried users_url(:id => alert.user.id). Which didn''t
through an error. But the links don''t work with "map.resources
:users"
because they look like this: /users?id=2
What is the proper syntax in this case?
I''m using
<% for comment in @comments %>
<div class="comment">
<h4><%= h(comment.title) %></h4>
<p><%= h(comment.message) %></p>
<p>Submitted by: <%= link_to( h(comment.user.name),
users_url(comment.user.id) ) %></p>
</div>
<% end %>
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---