refactored search
This commit is contained in:
@@ -6,6 +6,17 @@ class JanitorTrial < ActiveRecord::Base
|
||||
after_destroy :create_feedback
|
||||
validates_presence_of :user
|
||||
before_validation :initialize_creator
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
|
||||
if params[:user_name]
|
||||
q = q.where("user_id = (select _.id from users _ where lower(_.name) = ?)", params[:user_name].downcase)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
|
||||
def initialize_creator
|
||||
self.creator_id = CurrentUser.id
|
||||
|
||||
Reference in New Issue
Block a user