Class: ActiveFieldsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 18

def create
  @active_field = model_class.new(active_field_create_params(model_class))

  if @active_field.save
    redirect_to edit_active_field_path(@active_field), status: :see_other
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



38
39
40
41
42
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 38

def destroy
  @active_field.destroy!

  redirect_to active_fields_path, status: :see_other
end

#editObject



28
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 28

def edit; end

#indexObject



8
9
10
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 8

def index
  @active_fields = ActiveFields.config.field_base_class.order(:customizable_type, :id)
end

#newObject



14
15
16
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 14

def new
  @active_field = model_class.new
end

#showObject



12
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 12

def show; end

#updateObject



30
31
32
33
34
35
36
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 30

def update
  if @active_field.update(active_field_update_params(@active_field.class))
    redirect_to edit_active_field_path(@active_field), status: :see_other
  else
    render :edit, status: :unprocessable_entity
  end
end