Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Can filter pending playbacks by source
Browse files Browse the repository at this point in the history
  • Loading branch information
suninthesky committed Feb 15, 2019
1 parent 93a4a2b commit 3d81965
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/controllers/playbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ class PlaybacksController < ApplicationController
before_action :set_playback, only: %i[show edit update destroy]

def pending
@playbacks = Playback.where(comments_count: params[:comments] || 0)
@playbacks = Playback.query(:comments_count, params[:comments])
.query(:source, params[:source])
.order(:source, :comments_count)
end

def index
Expand Down
4 changes: 4 additions & 0 deletions app/models/playback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ class Playback < ApplicationRecord
validates_associated :sections

validates :organisation_name, :email, presence: true

def self.query(col, param)
param.blank? ? all : where(col => param)
end
end
2 changes: 1 addition & 1 deletion app/views/playbacks/pending.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="maxw1050 mx-auto px15">
<h1 class="h2 bold my40">Pending Playbacks</h1>

<table>
<table class="mb30">
<thead>
<tr>
<th>Organisation Name</th>
Expand Down

0 comments on commit 3d81965

Please sign in to comment.