Reputation: 39
when i try to link to users#show the id from the service become id for user for example if i'm watching service with id 3 that a user with id 1 has created and want link service.user.name take the id from service and will show me user with id 3
i have this in my view services/show
<%= link_to @service.user.name, user_path %>
users controller
def show
@user = User.find(params[:id])
end
routes
resources :users, :only => [:show]
thanks
Upvotes: 0
Views: 55
Reputation: 27747
This path:
user_path
needs to know which user you want to look at... you have to tell it which user eg:
link_to @service.user.name, user_path(@service.user)
Upvotes: 2