Class: Fae::NestedBaseController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Fae::NestedBaseController
- Defined in:
- app/controllers/fae/nested_base_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/fae/nested_base_controller.rb', line 23 def create @item = @klass.new(permitted_params) raise_undefined_parent if @item.fae_nested_parent.blank? if @item.save @parent_item = @item.send(nested_parent) flash[:notice] = t('fae.save_notice') render template: table_template_path else build_assets render action: 'new' end end |
#destroy ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/fae/nested_base_controller.rb', line 50 def destroy raise_undefined_parent if @item.fae_nested_parent.blank? @parent_item = @item.send(nested_parent) if @item.destroy flash[:notice] = t('fae.delete_notice') else flash[:alert] = t('fae.delete_error') end render template: table_template_path end |
#edit ⇒ Object
19 20 21 |
# File 'app/controllers/fae/nested_base_controller.rb', line 19 def edit build_assets end |
#new ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/controllers/fae/nested_base_controller.rb', line 10 def new @item = @klass.new raise_undefined_parent if @item.fae_nested_foreign_key.blank? item_id = params[:item_id].to_i || nil @item.send("#{parent_foreign_key}=", item_id) build_assets end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/fae/nested_base_controller.rb', line 37 def update raise_undefined_parent if @item.fae_nested_parent.blank? if @item.update(permitted_params) @parent_item = @item.send(nested_parent) flash[:notice] = t('fae.save_notice') render template: table_template_path else build_assets render action: 'edit' end end |