Class: Infold::AttachmentFieldsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Infold::AttachmentFieldsController
- Defined in:
- app/controllers/infold/attachment_fields_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/infold/attachment_fields_controller.rb', line 13 def create @model = Model.find(params[:model_id]) @attachment_field = @model..build @attachment_field.assign_attributes(post_params) if @attachment_field.save redirect_to , flash: { info: t('infold.flash.created') } else flash.now[:warning] = t('infold.flash.invalid') render 'new', status: :unprocessable_entity end end |
#destroy ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/infold/attachment_fields_controller.rb', line 41 def destroy @attachment_field = AttachmentField.find(params[:id]) @attachment_field.destroy! redirect_to (@attachment_field.model), status: :see_other, flash: { notice: t('infold.flash.destroyed') } end |
#edit ⇒ Object
25 26 27 28 |
# File 'app/controllers/infold/attachment_fields_controller.rb', line 25 def edit @attachment_field = AttachmentField.find(params[:id]) @model = @attachment_field.model end |
#index ⇒ Object
3 4 5 6 |
# File 'app/controllers/infold/attachment_fields_controller.rb', line 3 def index @model = Model.find(params[:model_id]) @attachment_fields = @model..sort_by(&:id) end |
#new ⇒ Object
8 9 10 11 |
# File 'app/controllers/infold/attachment_fields_controller.rb', line 8 def new @model = Model.find(params[:model_id]) @attachment_field = @model..build end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/infold/attachment_fields_controller.rb', line 30 def update @attachment_field = AttachmentField.find(params[:id]) @attachment_field.assign_attributes(post_params) if @attachment_field.save redirect_to (@attachment_field.model), flash: { info: t('infold.flash.updated') } else flash.now[:warning] = t('infold.flash.invalid') render 'edit', status: :unprocessable_entity end end |