Class: DefraRubyFeatures::FeatureTogglesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/defra_ruby_features/feature_toggles_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
# File 'app/controllers/defra_ruby_features/feature_toggles_controller.rb', line 18

def create
  model.create!(feature_toggle_params)

  redirect_to feature_toggles_path
end

#destroyObject



36
37
38
39
40
41
42
# File 'app/controllers/defra_ruby_features/feature_toggles_controller.rb', line 36

def destroy
  @feature_toggle = model.find_by(id: params[:id])

  @feature_toggle.destroy!

  redirect_to feature_toggles_path
end

#indexObject



10
11
12
13
14
15
16
# File 'app/controllers/defra_ruby_features/feature_toggles_controller.rb', line 10

def index
  # MongoId
  @feature_toggles = model.order(key: "ASC") if model.respond_to?(:order)

  # ActiveRecord
  @feature_toggles = model.order_by(key: "ASC").all if model.respond_to?(:order_by)
end

#newObject



32
33
34
# File 'app/controllers/defra_ruby_features/feature_toggles_controller.rb', line 32

def new
  @feature_toggle = model.new
end

#updateObject



24
25
26
27
28
29
30
# File 'app/controllers/defra_ruby_features/feature_toggles_controller.rb', line 24

def update
  @feature_toggle = model.find_by(id: params[:id])

  @feature_toggle.update!(feature_toggle_params)

  redirect_to feature_toggles_path
end