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
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
28 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 28 def edit; end |
#index ⇒ Object
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 |
#new ⇒ Object
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 |
#show ⇒ Object
12 |
# File 'lib/generators/active_fields/scaffold/templates/controllers/active_fields_controller.rb', line 12 def show; end |
#update ⇒ Object
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 |