Callum
Callum

Reputation: 1165

Rails linking url paths

I did not generate the complete user model and i do not know how i can link to the user profile. I have tried:

<%= link_to u.username, user_show_path(u) %>

However it only shows an error, if it's any difference I am also using the devise gem

Upvotes: 0

Views: 64

Answers (2)

Callum
Callum

Reputation: 1165

Sorted, used the link

link_to u.username, :controller => "users", :action => "show", :id => u

and then wrote a simple route,

match "/user/:id" => "users#show"

Upvotes: 0

Khallil Mangalji
Khallil Mangalji

Reputation: 481

There are many ways link_to can be used

  link_to u.username, user_path(u)
  link_to u.username, u
  link_to u.username, :controller => "users", :action => "show", :id => u

all should work, the issue could be that you are using user_show_path

Upvotes: 1

Related Questions