Class: DynamicFieldsets::FieldsetChildrenController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- DynamicFieldsets::FieldsetChildrenController
- Defined in:
- app/controllers/dynamic_fieldsets/fieldset_children_controller.rb
Overview
Controller for handling editing of fieldset children Most of this is done through the fieldsets#children action Dependencies are done here
Instance Method Summary collapse
- #edit ⇒ Object
-
#index ⇒ Object
this view doesn’t exist.
-
#remove ⇒ Object
deletes the fieldset child and redirects to its root fieldset page.
-
#show ⇒ Object
Show a record and all children.
-
#update ⇒ Object
updates the fieldset_child and uses accepts_nested_attributes_for to setup a dependency system.
Instance Method Details
#edit ⇒ Object
21 22 23 24 25 26 |
# File 'app/controllers/dynamic_fieldsets/fieldset_children_controller.rb', line 21 def edit @fieldset_child = DynamicFieldsets::FieldsetChild.find(params[:id]) respond_to do |format| format.html end end |
#index ⇒ Object
this view doesn’t exist
8 9 |
# File 'app/controllers/dynamic_fieldsets/fieldset_children_controller.rb', line 8 def index end |
#remove ⇒ Object
deletes the fieldset child and redirects to its root fieldset page
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/dynamic_fieldsets/fieldset_children_controller.rb', line 41 def remove @fieldset_child = DynamicFieldsets::FieldsetChild.find(params[:id]) root = @fieldset_child.root_fieldset respond_to do |format| if @fieldset_child.destroy notice_text = "Successfully removed the child" else notice_text = "Child was not able to be removed" end format.html { redirect_to(dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(root), :notice => notice_text)} end end |
#show ⇒ Object
Show a record and all children
12 13 14 15 16 17 18 19 |
# File 'app/controllers/dynamic_fieldsets/fieldset_children_controller.rb', line 12 def show @fieldset_child = DynamicFieldsets::FieldsetChild.find params[:id] @fieldset = DynamicFieldsets::Fieldset.find @fieldset_child.fieldset_id respond_to do |format| format.html end end |
#update ⇒ Object
updates the fieldset_child and uses accepts_nested_attributes_for to setup a dependency system
29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/dynamic_fieldsets/fieldset_children_controller.rb', line 29 def update @fieldset_child = DynamicFieldsets::FieldsetChild.find(params[:id]) respond_to do |format| if @fieldset_child.update_attributes(params[:dynamic_fieldsets_fieldset_child]) format.html { redirect_to(dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(@fieldset_child.root_fieldset), :notice => "Successfully updated a child")} else format.html { render :action => "edit" } end end end |