Using search_field as select

Hi,

I am trying to make the search_field look into a table of my database
which is different from the form’s object’s table.
Basically, I want to do this:

<%= f.search_field(:sport, Sport.all.collect {|s|[s.sport_name]}) %>

But it does not work obviously.

Sorry if this issue has already been raised but I did not find any
solution after searching on google and in this group posts.

Thank you in advance for your help,
Alex

What exactly are you trying to do? All that search_field does is create
a
HTML input with type=“search”

If you want a dropdown you should use collection_select or something
similar

Hi,

Thank you for your reply.
I solved my problem using Custom Form Builder. I created a custom form
field for the new HTML5 datalist. If anyone is interested, I can post my
solution which is definitely not optimal since I am new to rails.

regards,
Alexandre

On Mon, Jan 30, 2012 at 11:40 AM, Alexandre Balon-Perin
[email protected]wrote:

I’m also doing some searchs using fields, I used the autocomplete method
of
jquery (I saw that in a railscast)

@Javier:
I also watched the railscast but I prefer a “Ruby solution”.
The custom form builder is simple and very readable so I am gonna stick
with it. :slight_smile:

Anyway thank you for your reply, I appreciate it.
Alex

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