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

Add random sorting for the features page. #42

Merged
merged 1 commit into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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