Is it possible to pass parameters through link_to that will be used by
the controller that link_to directs to? Specifically I have this
code:
<% for user in @users -%>
<%= link_to user.screen_name, {:action => “index”, :controller =>
“users”, :user_id => user.id } %>
<% end %>
Is it possible to use the parameter at the end of link_to(:user_id =>
user.id) to initialize a hash @user using the user_id?
This is the index action in the users controller:
def index
@user = User.find(:all, :conditions => { :id => :user_id })
end
I dont know if this makes sense but ultimately I am trying to link to
a profile and have that profile be filled with the user that matches
the id of the link that is clicked. So I am trying to pass the id of
the user through link_to and use that id in the index action above to
populate a hash with the corresponding user. Im not sure if this is
the way to go about it. Ive been stuck on this for a while, so any
input is much appreciated. Thanks, Dave