Hello,
I am having difficulty with extracting data from the collection_select
form helper.
First, the code:
1. view ->>
<%= collection_select :colors, :id, send_colors, :id, :color %>
2. view helper that polulates collection_select ''send_colors''
-->>
def send_colors
@colors = Color.find(:all)
end
3. controller ->>
def create
@color = Color.new(params[:color])
end
My problem is that when I submit the form, @color (in the controller) is
not being populated with any data. I have inspected the @color object
and it''s attributes are empty. When I view the HTML source in the web
browser, the select form value options are there but seemingly not
submitted back to controller. Perhaps my controller code is wrong.
Also, here''s some debug YAML output
<%= debug(params) %>
--- !map:HashWithIndifferentAccess
commit: Save changes
action: create_debug
controller: admin
color: !map:HashWithIndifferentAccess
id: "1"
<%= debug(@color) %>
--- !ruby/object:Color
attributes:
color:
new_record: true
<%= debug(request) %>
partial output
#<ActionController::CgiRequest:0x3604d40
@parameters={"commit"=>"Save
changes", "action"=>"create_debug",
"controller"=>"admin",
"color"=>{"id"=>"1"}},
What is this ''HasWithIndifferentAccess'' about? Is this my
problem?
Thanks for any assistance in advance!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---