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:

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

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Tim Shaffer at Jan 30, 2012 at 4:30 pm
    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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/5Kke2y_WvhMJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Alexandre Balon-Perin at Jan 30, 2012 at 4:40 pm
    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 30 January 2012 17:30, Tim Shaffer wrote:

    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

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/rubyonrails-talk/-/5Kke2y_WvhMJ.

    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Javier Quarite at Jan 30, 2012 at 5:00 pm

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

    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
    I'm also doing some searchs using fields, I used the autocomplete method of
    jquery (I saw that in a railscast)

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Alexandre Balon-Perin at Jan 30, 2012 at 5:39 pm
    @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. :)

    Anyway thank you for your reply, I appreciate it.
    Alex
    On 30 January 2012 17:59, Javier Quarite wrote:



    On Mon, Jan 30, 2012 at 11:40 AM, Alexandre Balon-Perin <
    abalonpe@ulb.ac.be> wrote:
    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
    I'm also doing some searchs using fields, I used the autocomplete method
    of jquery (I saw that in a railscast)


    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 30, '12 at 11:05a
activeJan 30, '12 at 5:39p
posts5
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase