server-examples/ruby-example.rb
#This is an optional helper method similar to the one that devise provides. 
#Use this throughout the app to check if the user is logged in and to load/save data to/from their user record 
This is an optional helper method similar to the one that devise provides.
Use this throughout the app to check if the user is logged in and to load/save data to/from their user record
This is an optional helper method similar to the one that devise provides . Use this throughout the app to check if the user is logged in and to load / save data to / from their user record
def current_user 
  if session[:user_id]
    current_user = User.find_by(id: session[:user_id])
    if current_user 
      return current_user 
    end 
  end 
  return nil 
end
def current_user if session [ :user_id ] current_user = User . find_by ( id : session [ :user_id ] ) if current_user return current_user end end return nil end
This is an optional helper method similar to the one that devise provides.
This is an optional helper method similar to the one that devise provides .
#not logged in 