Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

select2 forms help

I've tried to follow the quick tip video from Jason link but I'm a little bit confused about how to implement it.

I had a text_field where you could manually type in the names of a performer like this:

<%= f.text_field :performer %>

I wanted to replace this with a select2 lookup which looked up my users and once I've selected a user I would then assign this to to the performer field.

<form> 
  <%= select_tag "performer", options_from_collection_for_select(@user, "id", "profile_name"),
 include_blank: true, id: "performer", 
data: { placeholder: "Choose a performer" } %>
</form>

The select box works and I can find and select my users but I'm not sure how to write it so that it takes this value and enters it into the performer field.

Can anyone help?

2 Answers

Anyone? :-( I imagine it's pretty simple, I just don't know how to construct it.

Sorry to bump this again (last time I promise!) but I'm still unsure how to construct this. I've even asked on stackoverflow and not got a response.

Can anyone help me? Before I have to beg Jason Seifer ?