Skip to content

Instantly share code, notes, and snippets.

@julianalucena
Forked from nataliaconde/sessions_controller.rb
Last active June 26, 2021 02:53
Show Gist options
  • Save julianalucena/a9385565332c9d8e1e2c99fc31090aee to your computer and use it in GitHub Desktop.
Save julianalucena/a9385565332c9d8e1e2c99fc31090aee to your computer and use it in GitHub Desktop.
Ruby controller/handler
# sessions_controller.rb
class SessionsController < ApplicationController
def create
@login_form = LoginForm.new(params)
if @user = @login_form.submit
sign_in @user
redirect_to @user, notice: "Welcome!"
else
render action: :new
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment