Skip to content

Commit

Permalink
Assign the session[:user_id] in development
Browse files Browse the repository at this point in the history
Previously, despite signing in a dummy user, this wasn't happening.
  • Loading branch information
olivierlacan committed Jun 25, 2015
1 parent dc76c7a commit 50a8bf7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -16,9 +16,11 @@ def current_user
user = nil

# In the development environment, your current_user will be the
# first User in the database. Easy enough ;-)
# first User in the database or a dummy one created below.
if !Rails.env.production?
user = User.first_or_create(email: "alvar@hanso.dk", name: "Alvar Hanso")
session[:user_id] = user.id
flash[:notice] = "Signed in!"
else
user = User.find(session[:user_id]) if session[:user_id].present?
end
Expand Down

0 comments on commit 50a8bf7

Please sign in to comment.