Drop down menu - getting @params[:id] value

I am looking to get my option drop down list to populate from a model.
In my controller i’m using:

@roles = Role.find(:all, :order => “name”)

in my view I have:
<%= collection_select(:id, :name, @roles, :id, :name) %> role <%=
submit_tag(“Go”) %>

I cannot get just the id of the selected option. If i inspect the params
I get:

{“commit”=>“Go”, “action”=>“view_role_rights”, “id”=>{“name”=>“1”},
“controller”=>“accounts”}

What is going on there? can anyone help?

James W. wrote:

I get:

{“commit”=>“Go”, “action”=>“view_role_rights”, “id”=>{“name”=>“1”},
“controller”=>“accounts”}

What is going on there? can anyone help?

I’m somewhat confused why you are supplying :id and :name as first two
arguments. They should be the ActiveRecord::Base object and the method,
for
instantace, “post” and “author_id”. I’m guessing your roles are for
users,
so you’d need something like “user” and “role_id”.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs