Home How to display ransack checkbox in custom order
Reply: 0

How to display ransack checkbox in custom order

user1415
1#
user1415 Published in June 19, 2018, 6:29 pm

I am building a rails job app and using the ransack gem. In creating a job post, users have the ability to choose the type of job from a collection. This is the code for that

<%= f.input :role, collection: ["Fullstack Developer", "Backend 
 Developer", "Frontend Developer", "Engineer", "IOS Developer", 
 "Android Developer", "Designer", "Business Developer"], :label => 
 "Role" %>

In my job index, I display this collection with ransack. The code is below

<div class="filter-style">
  <h4>Roles</h4>
  <% new_roles = [] %>
  <%= search_form_for @search, :class => 'filters_click' do |f| %>
    <% @jobs.each do |job| %>
      <% if job.role? %>
        <% new_roles << job.role %>
      <% end %>
    <% end %>

    <% new_roles.uniq.each do |new_role| %>
      <div class="styled-input-container">
        <a>
          <label>
            <%= check_box_tag('q[role_eq_any][]', new_role) %>
              <%= new_role %>
          </label>
        </a>
      </div>
    <% end %>
  <% end %>
</div>

What i want is to display the collection in the same order as in the job new page. For example, i want to display in order of "Fullstack Developer", "Backend Developer" etc.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.318188 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO