Skip to content

Instantly share code, notes, and snippets.

@scottmessinger
Created February 11, 2011 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottmessinger/822598 to your computer and use it in GitHub Desktop.
Save scottmessinger/822598 to your computer and use it in GitHub Desktop.
-semantic_form_for @presenter.sequence, :action => 'update', :html => {:id => 'edit_narrative'} do |s|
-s.semantic_fields_for :unit, :index => nil do |u|
-u.inputs do
=u.input :narrative_sidebar, :label => false,:as => :text, :input_html => {:class => 'mceEditorNarrative'}, :wrapper_html => { :id => 'narrative_sidebar'}
=u.input :narrative, :label => false, :input_html => {:class => 'mceEditorNarrative'}, :as => :text, :wrapper_html => {:id => 'main_narrative'}
=u.input :narrative_sidebar_flag, :as => :boolean, :label => "Enable Sidebar:", :wrapper_html => {:class => 'enable_narrative_sidebar'}, :input_html => {:type => "checkbox"}
-s.buttons do
=s.commit_button :label => 'Update'
Processing SequencesController#update (for 127.0.0.1 at 2011-02-11 11:29:33) [PUT]
Parameters: {"sequence"=>{"unit_attributes"=>[{"narrative"=>"<p>r</p>", "narrative_sidebar"=>"<p>qwww</p>", "narrative_sidebar_flag"=>"0"}, {"id"=>"4d13127061dec5b7c5000354", "narrative_sidebar_flag"=>"1"}]}, "commit"=>"Update", "action"=>"update", "_method"=>"put", "authenticity_token"=>"8adrIz3srZfl0AfFEqcCebWWB40SoyzQg07MEpsgGXM=", "id"=>"4d13127061dec5b7c5000355", "controller"=>"sequences"}
###
As you can see, the unit_attributes key is an array, as it should be. What's odd is the checkbox adds another element to the array, as if I was updating 2 units. Also, the ID of the unit is only included in the second element, only the data in the second element gets saved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment