Class: Guts::OptionsController

Inherits:
ApplicationController show all
Includes:
ControllerPermissionConcern
Defined in:
app/controllers/guts/options_controller.rb

Overview

Options controller

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability

Methods included from MultisiteConcern

#current_site, #with_current_site

Instance Method Details

#createObject

Note:

Redirects to #index if successfull or re-renders #new if not

Creates an option through post



32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/guts/options_controller.rb', line 32

def create
  @option = Option.new option_params

  if @option.save
    flash[:notice] = 'Option was successfully created.'
    redirect_to edit_option_path(@option)
  else
    render :new
  end
end

#destroyObject

Destroys an option



55
56
57
58
59
60
# File 'app/controllers/guts/options_controller.rb', line 55

def destroy
  @option.destroy

  flash[:notice] = 'Option was successfully destroyed.'
  redirect_to options_path
end

#editObject

Editing of an option



27
28
# File 'app/controllers/guts/options_controller.rb', line 27

def edit
end

#indexObject

Display a list of options



13
14
15
# File 'app/controllers/guts/options_controller.rb', line 13

def index
  @options = Option.paginate(page: params[:page], per_page: @per_page)
end

#newObject

Creation of a new option



22
23
24
# File 'app/controllers/guts/options_controller.rb', line 22

def new
  @option = Option.new
end

#showObject

Show a single options



18
19
# File 'app/controllers/guts/options_controller.rb', line 18

def show
end

#updateObject

Note:

Redirects to #index if successfull or re-renders #edit if not

Updates an option through patch



45
46
47
48
49
50
51
52
# File 'app/controllers/guts/options_controller.rb', line 45

def update
  if @option.update option_params
    flash[:notice] = 'Option was successfully updated.'
    redirect_to edit_option_path(@option)
  else
    render :edit
  end
end