user558138
user558138

Reputation: 167

saving selection from collection_select and passing to controller

I have a dropdownmenu which populates from the database. I'm using the following code to do it:-

<%= collection_select(:abc, :SkillSetName, @technologies, :id, :Topic) %>

I have no idea what :abc and :SkillSetName are doing here. I just know that the drop down is being populated with :Topic from my @technologies variable. I want to save the selection made by the user from the drop down menu and send it to the next controller action. I don't want to use f.collection_select

Upvotes: 1

Views: 1799

Answers (3)

Hitesh
Hitesh

Reputation: 825

:abc stand for your object and :SkillSetName stand for your method.

when you want to save its value you can get it using params[:abc][:SkillSetName]

Upvotes: 0

Mischa
Mischa

Reputation: 43318

If you don't know what :abc and :SkillSetName are, how are we supposed to know?

Anyway, the user's selection will be in:

params[:abc][:SkillSetName]

If you want to understand what you are doing, have a look at the API for collection_select.

Upvotes: 1

Anton
Anton

Reputation: 1401

See my answer - RoR: collection_select not setting the value in the DB

Upvotes: 0

Related Questions