Update snps_controller.rb

quickly fixed my own code review to get the ball rolling. :)
This commit is contained in:
Bastian Greshake Tzovaras
2017-09-05 16:34:51 +01:00
committed by GitHub
parent 9e9ec11f6f
commit b20323f34e

View File

@@ -1,12 +1,11 @@
# frozen_string_literal: true
class SnpsController < ApplicationController
helper_method :sort_column, :sort_direction
before_filter :find_snp, except: [:index, :json,:json_annotation]
def index
params.delete(:sort)
params.delete(:direction)
@snps = Snp.order(sort_column + ' ' + sort_direction)
@snps = Snp.order(ranking: :desc)
@snps_paginate = @snps.paginate(page: params[:page], per_page: 10)
@title = 'Listing all SNPs'
end
@@ -177,15 +176,7 @@ class SnpsController < ApplicationController
end
private
def sort_column
Snp.column_names.include?(params[:sort]) ? params[:sort] : 'ranking'
end
def sort_direction
%w[asc desc].include?(params[:direction]) ? params[:direction] : 'desc'
end
def json_element(params)
# TODO: Refactor this. - Helge
@result = {}