I''m trying to create a list of options with the top item returning
""
while displaying none
<%= select (:activity, :location_state, [["None",""]]+
@client.location_addresses.map {|location|
[location.state,location.state]}.uniq.sort, {:selected =>
@location_state_selected }) %>
This generates what I would think would be the right option tags (and
they look right in show source as well) but when it''s returned to the
server :location_state => "None" insead of ""
What gives? Any ideas?
Thanks,
-dustin
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi. Try write [["", "None"]]
first - value, second - the displaying string.
Another way - using parameter :prompt => "None", in your case:
<%= select (:activity, :location_state,
@client.location_address.map{|location| [location.state,
location.state]}.uniq.sort, {:prompt => "None"}, {:selected =>
@location_state_selected}) %>
Best Regards, Sergey
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
Hmm I figured out where the problem is coming from. I''m using
observe_form to watch for changes in this form. The params that are
getting to the :url in observe_form are wrong. I''ve written a simple
test case:
Two rhtml files will show what I''m talking about:
params_test.rhtml:
<html>
<head>
<title>params</title>
<%= javascript_include_tag "prototype" %>
</head>
<body>
<%= form_tag ({:action => "render_params"}, {:id =>
''form''}) %>
<%= select (:activity, :location_type, [["Store","0"],
["DC", "1"]],
{:prompt => "None"}) %>
<%= submit_tag %>
<%= observe_form(:form,
:update => ''params'',
:url => {:action => ''render_params''}) %>
<div id=''params''></div>
</body>
</html>
render_params:
<html>
<head>
<title>render_params</title>
</head>
<body>
params:<br/>
<%= debug(params) %>
request.params:<br/>
<%= debug(request.params) %>
</body>
</html>
Now if I submit the form render_params returns:
params:
--- !map:HashWithIndifferentAccess
commit: Save changes
activity: !map:HashWithIndifferentAccess
location_type: ""
action: render_params
controller: params_test
request.params:
---
commit:
- Save changes
activity[location_type]:
- ""
If I change the form the ''params'' div gets updated with:
--- !map:HashWithIndifferentAccess
commit: Save changes
activity: !map:HashWithIndifferentAccess
location_type: None
action: render_params
controller: params_test
request.params:
---
commit:
- Save changes
activity[location_type]:
- None
Notice activity[location_type] is "None"! Argh!!! What is going on
here???
Thanks for any and all help,
-dustin
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
Weird it was a bug with the prototype library that shipped with Rails on Locomotive. I updated my prototype.js file (which is smaller than the one that was in public/javascripts/) and it started working. Should I report a bug somewhere to someone (Locomotive?) -dustin --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---