You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
hi i m using rails 4 and i have this error shows in current_user helper method .
ActiveRecord::RecordNotFound in UsersController#new
Couldn't find User without an ID
and My code for pplication_controller.rb:
def current_user
@current_user ||= User.find(session[:user_id]) if session [:user_id]
end
and this is my code of user_controller.rb:
def new @user= User.new
end
def create @user= User.new(params[:user])
if @user.save
redirect_to root_url, :notice => "Signed up!"
else
render "new"
end
end
and now this is my code for application.html.erb where i check current_user:
<% if current_user %>
Logged in as <%= current_user.email %>,
<%= link_to "Log out", log_out_path %>
<% else %>
<%= link_to "Sign up", sign_up_path %>
<%= link_to "log in", log_in_path %>
<% end -%>
Screenshot
The text was updated successfully, but these errors were encountered:
hi i m using rails 4 and i have this error shows in current_user helper method .
ActiveRecord::RecordNotFound in UsersController#new
Couldn't find User without an ID
and My code for pplication_controller.rb:
def current_user
@current_user ||= User.find(session[:user_id]) if session [:user_id]
end
and this is my code of user_controller.rb:
def new
@user= User.new
end
def create
@user= User.new(params[:user])
if @user.save
redirect_to root_url, :notice => "Signed up!"
else
render "new"
end
end
and now this is my code for application.html.erb where i check current_user:
Screenshot
The text was updated successfully, but these errors were encountered: