add pool sort option
This commit is contained in:
@@ -40,6 +40,12 @@ class Pool < ActiveRecord::Base
|
||||
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
||||
end
|
||||
|
||||
if params[:sort] == "updated_at"
|
||||
q = q.order("updated_at desc")
|
||||
else
|
||||
q = q.order("name")
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
<%= search_field "name_matches", :label => "Name" %>
|
||||
<%= search_field "description_matches", :label => "Description" %>
|
||||
<%= search_field "creator_name", :label => "Creator" %>
|
||||
|
||||
<div class="input">
|
||||
<label>Order</label>
|
||||
<%= select "search", "sort", [["Name", "name"], ["Last updated", "updated_at"]] %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user