Skip to content

Commit

Permalink
small starting fixes
Browse files Browse the repository at this point in the history
calling child.type on fieldset controller was giving the name of the
  STI child of DynamicFieldsets::Field, now passing class name directly
children page now prints error messages when update fails
'Back' link on fieldset child now links back to parent 'children' page
rearranged a route b/c fieldset/roots was matching fieldset/:id
  • Loading branch information
Alfredo Uribe committed Jul 31, 2013
1 parent 2af1363 commit 2a1c44e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def edit
# updates the fieldset_child and uses accepts_nested_attributes_for to setup a dependency system
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")}
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/dynamic_fieldsets/fieldsets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def associate_child
if(@fieldset_child.nil?)
@fieldset_child = DynamicFieldsets::FieldsetChild.new(
:child_id => @field.id,
:child_type => @field.class.name,
:child_type => "DynamicFieldsets::Field",
:fieldset_id => @fieldset.id,
:order_num => DynamicFieldsets::FieldsetChild.where(:fieldset_id => @fieldset.id).count + 1)
else
Expand All @@ -82,7 +82,7 @@ def associate_child
end
format.html { redirect_to(dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(@fieldset), :notice => notice_text )}
else
format.html { redirect_to(dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(@fieldset), :notice => "Field was not successsfully associated." )}
format.html { redirect_to(dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(@fieldset), :notice => @fieldset_child.errors) }
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<tr>
<td><%= f.select :fieldset_child_id, options_for_select(DynamicFieldsets::FieldsetChild.all.collect { |c| [c.child.name, c.id]}, obj.fieldset_child_id)%></td>
<td><%= f.select :fieldset_child_id, options_for_select(DynamicFieldsets::FieldsetChild.all.select { |x| x.child.type != "DynamicFieldsets::InstructionField" }.collect { |c| [c.child.name, c.id]}, obj.fieldset_child_id)%></td>
<td><%= f.select :relationship, DynamicFieldsets::Dependency::RELATIONSHIP_LIST %></td>
<td><%= f.text_field :value %></td>
<td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= select_tag(name, options_from_collection_for_select( collection, :id, :name, selected_id ), attrs) %>
<%= select_tag(name, options_from_collection_for_select( collection, :id, :name, selected_id ), attrs.merge({:include_blank => true})) %>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace :dynamic_fieldsets do
resources :fieldset_associators

resources :fieldsets
match "/fieldsets/roots" => "fieldsets#roots"
resources :fieldsets
match "/fieldsets/:id/children" => "fieldsets#children", :as => :children_dynamic_fieldsets_fieldset
match "/fieldsets/:id/children/reorder" => "fieldsets#reorder"
match "/fieldsets/new(/:parent)" => "fieldsets#new", :as => :new_dynamic_fieldsets_fieldset
Expand Down

0 comments on commit 2a1c44e

Please sign in to comment.