add pool sort option

This commit is contained in:
albert
2013-02-17 15:43:44 -05:00
parent 327ad8fbb6
commit 351e4d426a
2 changed files with 12 additions and 0 deletions

View File

@@ -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

View File

@@ -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>