Class: SessionGem::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SessionGem::SessionsController
- Includes:
- ActiveStorage::SetCurrent
- Defined in:
- app/controllers/session_gem/sessions_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/session_gem/sessions_controller.rb', line 16 def create @session = Session.new(session_params) if @session.save redirect_to @session else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
38 39 40 41 42 |
# File 'app/controllers/session_gem/sessions_controller.rb', line 38 def destroy @session = Session.find(params[:id]) @session.destroy redirect_to root_path end |
#edit ⇒ Object
25 26 27 |
# File 'app/controllers/session_gem/sessions_controller.rb', line 25 def edit @session = Session.find(params[:id]) end |
#index ⇒ Object
4 5 6 |
# File 'app/controllers/session_gem/sessions_controller.rb', line 4 def index @sessions = Session.all end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/session_gem/sessions_controller.rb', line 12 def new @session = Session.new end |
#show ⇒ Object
8 9 10 |
# File 'app/controllers/session_gem/sessions_controller.rb', line 8 def show @session = Session.find(params[:id]) end |
#update ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/controllers/session_gem/sessions_controller.rb', line 29 def update @session = Session.find(params[:id]) if @session.update(session_params) redirect_to @session else render :edit, status: :unprocessable_entity end end |