1

For my user form, I have a hobbies drop-down menu and I want to be able to select more than one option (one user may have skiing, reading, and chess as hobbies).

Of course, doing this is very easy!

However, none of the available options seem to work for me...

Here's my code:

<%= f.select :hobbies, [['Chess','chess'],
                        ['Movies','movies'],
                        ['Videogames','videogames'],
                        ['Skiing', 'skiing'],
                        ['Reading','reading']],
                        {:multiple => true} %>

However, when I look at my form, I don't think this is working. It makes the drop-down menu....but how do I select multiple entries? I try ctr + click but it doesn't do anything....what am I missing? It keeps just selecting one value only...

1 Answer 1

2

Take a look at the accepted answer to that question - the method signature is:

select(:type, [data], {options hash}, {second options hash})

And in the answer, it has multiple: true in the second options hash.

API dock for select_tag gives a hint about what the two different hashes are for - it looks like the first options hash is for "option_tags", and the second one is for "options"

Sign up to request clarification or add additional context in comments.

1 Comment

The important thing to remember here is that if a function has multiple hash arguments, you must encapsulate your arguments within curly braces in order to separate them. select(type, data, options, {options}) will ignore the final hash argument whereas select(type, data, {options}, {options}) will not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.