Dark Ambient
2006-Oct-13 00:10 UTC
Help needed - Observe_form , passing parameters but ...
I think after 3 days I"m getting closer to getting my observe_form to work. At least now it''s rendering the partial , only with a nomethod (nil) error. Here is the problem -> I don''t think I know how to grab the params correctly off the form. Here is the form - <div id="parta"> <form id="asearch"> <fieldset><legend>Category</legend> <select name=position[category_id][] size = "4" multiple = "multiple" id ''cat''><%options_from_collection_for_select @categories, :id, :name %></select></fieldset> <fieldset><legend>State</legend> <select name=position[state_id][] size = "4" multiple = "multiple" id ''stat''><%options_from_collection_for_select @states, :id, :name %></select></fieldset> <fieldset><legend>Terms</legend> <select name=position[term_id][] size = "4" multiple = "multiple" id ''term''><%options_from_collection_for_select @terms, :id, :name %></select></fieldset> <fieldset><legend>Title</legend> <input type="text" id="title" name="position[title]" size="10" id = ''title'' /></fieldset> <fieldset><legend>City</legend> <input type="text" id="city" name="position[city]" size="10" id = ''city'' /></fieldset> </form> </div> <%= image_tag("roller.gif", :align => ''center'', :border => 0, :id => "roller", :style => "display: none;") %> <%= observe_form "asearch", :frequency => 0.5, :update => ''table'', :before => "Element.show(''roller'')", :success => "Element.hide(''roller'')", :url => ''list'', :with => "asearch" %> <div id="partb"> <div id="table"> <%= render :partial => "positions_list", :layout => false %> </div> </div> From the server log , the parameters being sent - Parameters: {"asearch"=>"position[state_id][]=35", "action"=>"list", "controller"=>"ajaxsearch", "position"=>{"city"=>"Boston", "title"=>"", "term_id"=>["3"]}} So the user can pick any number of choices in any number of elements One thing that looks weird in the parameters above is - "asearch"=>"position[state_id][]=35" as opposed to "position"=>{"city"=>"Boston" and "term_id"=>["3"]} anyway since the label names are position[field] in the controller I did a @positions = Position.new(params[:position]) Yes as I said above getting a nil error on the finds. Anyone ? Stuart -- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---