I'm learning Rails, following a book that has the following code:
UserController
class UsersController < ApplicationController
def new
@user = User.new
end
def edit
@user = User.find(params[:id])
end
def show
@user = User.find(params[:id])
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to @user, :notice => 'Cadastro realizado'
else
render :new
end
end
end
show.html.erb
<p id="notice"><%=notice%></p>
<h2>Perfil: <%[email protected]_name %></h2>
<ul>
<li>Localização: <%= @user.location %> </li>
<li>Bio: <%= @user.bio %></li>
</ul>
<%= link_to 'Editar Perfil', edit_user_path(@user) %>
<%= link_to 'Mostrar Perfil', show_user_path(@user) %>
Actually the book only goes up to the code edit_user_path
, however I wanted to do some tests and I'm not understanding why when I use the how_user_path
it says that the method does not exist instead of returning the same user, for only
<%= link_to 'Mostrar Perfil', @user %>
The code works, but I would like to know why with show_user_path
it returns an error being that the method obviously exists in controller , my goal would be to show the profile that was created.