I\'m trying to create a User show
page (that will function as a profile page) but am confused about how to do this with Devise. It doesn\'t seem as though Devi
showing current_user/ other_user profiles with devise:
After installing devise
Create a Users controller:
rails generate controller Users
Then create a show action and find the user with params id:
def show
@user = User.find(params[:id])
end
Create a show.html.erb file in the User view folder:
<%= @user.email %>
Linking to users show page:
<%= link_to "current_user_show", current_user %>
Now if you want to view other profiles create a index action in the users controller:
def index @users = User.all end
Create an index.html.erb in the User view folder then:
<% @users.each do |user| %>
<%= link_to user.username, user %>
<%= user.email %>
<% end %>
The link for this will be:
<%= link_to "show_index_of_users", users_path %>
This will link you to the users index.html.erb file there you will create a loop and link to users profile:
<% @users.each do |user| %>
<%= link_to user.username, user %>
<%= user.email %>
<% end %>
This should work!