Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #42 from connorshea/randomize-features-page
Browse files Browse the repository at this point in the history
Add random sorting for the features page.
  • Loading branch information
connorshea committed May 7, 2018
2 parents ec69986 + 5c7d05e commit 7fc701f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/features_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def index
end

@feature_count = features.count

if params["random"] == "true"
features = features.order(Arel.sql('random()'))
end

@features = features.page(params[:page])

@browsers = Rails.configuration.browsers
Expand Down
16 changes: 16 additions & 0 deletions app/views/features/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
class: "form-control") %>
</div>


<div class="form-group-title">
Sort
</div>
<div class="form-group">
<div class="form-check">
<%= check_box_tag(
"random",
"true",
(true if params["random"].present? && params["random"] == "true"),
{id: :random, class: "form-check-input"}
) %>
<%= label_tag(:random, "Random", class: "form-check-label") %>
</div>
</div>

<div class="form-group-title">
Categories
</div>
Expand Down

0 comments on commit 7fc701f

Please sign in to comment.