Forum: Ruby on Rails select_tag problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1cc3819533402344514d612e1bcfc5c1?d=identicon&s=25 Radu Spineanu (Guest)
on 2006-04-01 19:47
Hi

I have a feeds db described like this:

| id    | int(11)      | NO   | PRI |         | auto_increment |
| url   | varchar(255) | YES  |     |         |                |
| name  | varchar(255) | YES  |     |         |                |
| type  | varchar(255) | YES  |     |         |                |
| valid | int(11)      | YES  |     |         |                |

In my feeds view i have :

----
<!--[form:feed]-->
<p><label for="feed_url">URL</label><br/>
<%= text_field 'feed', 'url'  %></p>

<p><label for="feed_name">Name</label><br/>
<%= text_field 'feed', 'name'  %></p>

<p><label for="feed_type">Type</label><br/>
<%= select_tag 'feed[type]', options_for_select( { "Option1" => "opt1",
"Option2" => "opt" }) %>
<!--[eoform:feed]-->
----

If the data is sent .save and update_attributes doesn't save the type
field even though it's sent correctly through the hash (it uses
select_tag):

  Parameters: {"feed"=>{"name"=>"name", "url"=>"http://url.com",
"type"=>"opt1"}, "commit"=>"Edit", "action"=>"update", "id"=>"5",
"controller"=>"feeds"}

This version however works:
    @feed = Feed.find(params[:id])
    @feed.type = params[:feed][:type]
    if @feed.update_attributes(params[:feed])
[...]

Any ideas on how to fix the select_tag issue ?

Thanks
This topic is locked and can not be replied to.