Class: OptimacmsOptions::Admin::OptionsController

Inherits:
Optimacms::Admin::AdminBaseController
  • Object
show all
Defined in:
app/controllers/optimacms_options/admin/options_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/optimacms_options/admin/options_controller.rb', line 26

def create
  # input
  @option = Option.new(option_params)

  @res = @option.save

  respond_to do |format|
    if @res

      format.html {
        #redirect_to @user, notice: 'User was successfully created.'
        redirect_to admin_options_path, notice: 'Congratulations! You just create option!'
      }

    else
      format.html {
        render :new
      }

    end
  end
end

#editObject



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

def edit
  @option = Option.find(params[:id])
end

#indexObject



14
15
16
# File 'app/controllers/optimacms_options/admin/options_controller.rb', line 14

def index
  @items = Option.by_filter(@filter)
end

#newObject



18
19
20
# File 'app/controllers/optimacms_options/admin/options_controller.rb', line 18

def new
  @option = Option.new
end

#updateObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/optimacms_options/admin/options_controller.rb', line 49

def update
  @id = params[:id]

  @option = Option.find(@id)

  @res = @option.update(option_params)

  respond_to do |format|
    if @res
      format.html {
        redirect_to admin_options_path, notice: 'Congratulations! You just edit option!'
      }
      #format.json { render :show, status: :ok, location: @user }
    else
      format.html { render :edit }
      #format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end