Hi all,
I'm trying to serialize a form with the exception of one specific
element.
Serializing the form in a hash (without pulling out specific elements)
works:
<li>
<%= link_to_remote '(Save)', {:url => post_path(@post), :with => "$
('post_form').serialize(true)" }, :method => :put %>
</li>
The generated code is:
<li><a href="#" method="put" onclick="new Ajax.Request('/posts/1',
{asynchronous:true, evalScripts:true, parameters:$
('post_form').serialize(true)}); return false;">(Save)</a></li>
Ajax request goes through (a post (with the put method appended) is
sent to /posts/1) and the update.rjs file is called. Life is good so
far.
In the development log this is shown (removed Session ID for brevity):
Processing PostsController#update (for 127.0.0.1 at 2007-07-03
18:53:46) [PUT]
Parameters: {"commit"=>"Publish",
"post"=>{"title"=>"asdfasdfadfaf", "body"=>"afdasdf", "tag_list"=>"",
"teaser"=>"adsfadf"}, "_method"=>"put", "action"=>"update", "id"=>"1",
"controller"=>"posts"}
Attempting to remove a key from the serialized hash blows everything
up.
Here is the code that I tried to use to remove a key:
<li><%= link_to_remote '(Save)', { :url => post_path(@post),
:with => "$H($
('post_form').serialize(true)).remove('post[tag_list]')" }, :method
=> :put %>
</li>
The generated code is:
<li><a href="#" method="put" onclick="new Ajax.Request('/posts/173',
{asynchronous:true, evalScripts:true, parameters:$H($
('post_form').serialize(true)).remove('post[tag_list]')}); return
false;">(Save)</a>
When this happens, there is a POST sent but to the wrong URL (and I
get a 404). This appears in the logs (again Session removed for
brevity):
Processing PostsController#1 (for 127.0.0.1 at 2007-07-03 18:52:38)
[POST]
Parameters: {"action"=>"1", "controller"=>"posts"}
ActionController::UnknownAction (No action responded to 1):
It looks like perhaps when I call $H and the remove method it whacks
the entire hash.
Am I calling the wrong method, if so how can I remove one key during
serialization? Am I doing things the hard way?
Any help would be appreciated.
Thanks,
Carlos
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---