:
root "welcome#index"
resources :articles, :projects, :users
resources sessions, only: [:new, :create, :destroy], path_names: { new: "login", create: "login", destroy: "logout" }
Rails - _path _url
_path, , (/path).
_url (http://domain.com/path)
, :
get "/login" ( ) , .
As mentioned @Sergio Tulentsev, your method createand method destroymust be fixed to use the correct path helpers:
def create
@user = User.find_by email: params[:session][:email]
if @user && @user.authenticate(params[:session][:password])
session[:user_id] = @user.id
redirect_to root_path
else
redirect_to login_path
end
end
def destroy
...
redirect_to root_path
end
For a team render :newworth taking @Sergio!
source
share