Class: Guts::OptionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Guts::OptionsController
- Defined in:
- app/controllers/guts/options_controller.rb
Overview
Options controller
Instance Method Summary collapse
-
#create ⇒ Object
Creates an option through post.
-
#destroy ⇒ Object
Destroys an option.
-
#edit ⇒ Object
Editing of an option.
-
#index ⇒ Object
Display a list of options.
-
#new ⇒ Object
Creation of a new option.
-
#show ⇒ Object
Show a single options.
-
#update ⇒ Object
Updates an option through patch.
Methods included from SessionsHelper
#current_user, #log_in, #log_out, #logged_in?
Instance Method Details
#create ⇒ Object
Note:
Redirects to #index if successfull or re-renders #new if not
Creates an option through post
29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/guts/options_controller.rb', line 29 def create @option = Option.new option_params if @option.save redirect_to , notice: "Option was successfully created." else render :new end end |
#destroy ⇒ Object
Destroys an option
50 51 52 53 |
# File 'app/controllers/guts/options_controller.rb', line 50 def destroy @option.destroy redirect_to , notice: "Option was successfully destroyed." end |
#edit ⇒ Object
Editing of an option
24 25 |
# File 'app/controllers/guts/options_controller.rb', line 24 def edit end |
#index ⇒ Object
Display a list of options
10 11 12 |
# File 'app/controllers/guts/options_controller.rb', line 10 def index @options = Option.paginate(page: params[:page], per_page: @per_page) end |
#new ⇒ Object
Creation of a new option
19 20 21 |
# File 'app/controllers/guts/options_controller.rb', line 19 def new @option = Option.new end |
#show ⇒ Object
Show a single options
15 16 |
# File 'app/controllers/guts/options_controller.rb', line 15 def show end |
#update ⇒ Object
Note:
Redirects to #index if successfull or re-renders #edit if not
Updates an option through patch
41 42 43 44 45 46 47 |
# File 'app/controllers/guts/options_controller.rb', line 41 def update if @option.update option_params redirect_to , notice: "Option was successfully updated." else render :edit end end |