Class: ActiveFieldsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ActiveFieldsController
- Defined in:
- lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 16 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 |
#destroy ⇒ Object
36 37 38 39 40 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 36 def destroy @active_field.destroy! redirect_to active_fields_path, status: :see_other end |
#edit ⇒ Object
26 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 26 def edit; end |
#index ⇒ Object
6 7 8 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 6 def index @active_fields = ActiveFields.config.field_base_class.order(:customizable_type, :id) end |
#new ⇒ Object
12 13 14 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 12 def new @active_field = model_class.new end |
#show ⇒ Object
10 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 10 def show; end |
#update ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 28 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 |