0

I have a form_tag in Rails as below:

    <%= form_tag(listings_path, method: :get) do %>
      What 
      <%= text_field_tag :title, "",class: 'form-control' %>

      Category
      <%= select_tag(:category_id, options_from_collection_for_select(Category.all, :id, :name), { :prompt => 'All Categories' }) %>

      Area 
      <%= select_tag(:area, options_for_select(['All', 'Ireland', 'UK']), class: "form-control") %>

      <%= submit_tag 'Search', name: nil, class: "btn btn-primary" %>
    <% end %>

Where should I add the CSS option >> class: "form-control" << for the Area field to have it working? I tried few options I found on SO but no luck

1
  • I'm sorry, my mistake. I need to do this for the Category field. Area is working fine Commented Dec 29, 2017 at 19:11

3 Answers 3

3

I set it up just a little bit different than you in my apps but this works.

...

<% options = options_from_collection_for_select(Category.all, :id, :name) %>
<%= f.select :category_id,  options, class: "form-control", :include_blank => 'All Categories' %>

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

Comments

0
<%= select_tag "area", options_for_select(['All', 'Ireland', 'UK']), :include_blank => '--Choose an option--', class: 'form-control' %>

Comments

-1

Go to App>>assets>>stylesheets and post in any of the scss pages

Comments

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.