diff --git a/Gemfile b/Gemfile index 889743e3d..2b370d786 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '4.0.3' +gem 'rails', '4.1.0' gem 'rails-observers' gem 'activerecord-session_store' @@ -14,8 +14,8 @@ gem 'json' # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', '~> 4.0.1' - gem 'coffee-rails', '~> 4.0.1' + gem 'sass-rails' + gem 'coffee-rails' gem 'uglifier' end diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb index c0d057c96..a33220457 100644 --- a/app/models/organization/search.rb +++ b/app/models/organization/search.rb @@ -41,21 +41,15 @@ returns # fallback do sql query # - stip out * we already search for *query* - query.gsub! '*', '' - organizations = Organization.find( - :all, - :limit => limit, - :conditions => ['name LIKE ? OR note LIKE ?', "%#{query}%", "%#{query}%"], - :order => 'name' - ) + organizations = Organization.where( + 'name LIKE ? OR note LIKE ?', "%#{query}%", "%#{query}%" + ).order('name').limit(limit) # if only a few organizations are found, search for names of users if organizations.length <= 3 - organizations_by_user = Organization.select('DISTINCT(organizations.id)').joins('LEFT OUTER JOIN users ON users.organization_id = organizations.id').find( - :all, - :limit => limit, - :conditions => ['users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?', "%#{query}%", "%#{query}%", "%#{query}%"], - :order => 'organizations.name' - ) + organizations_by_user = Organization.select('DISTINCT(organizations.id)').joins('LEFT OUTER JOIN users ON users.organization_id = organizations.id').where( + 'users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?', "%#{query}%", "%#{query}%", "%#{query}%" + ).order('organizations.name').limit(limit) organizations_by_user.each {|organization_by_user| organization_exists = false organizations.each {|organization| diff --git a/app/models/ticket/search.rb b/app/models/ticket/search.rb index d61469584..14abbacb2 100644 --- a/app/models/ticket/search.rb +++ b/app/models/ticket/search.rb @@ -91,8 +91,8 @@ returns where(conditions). where( '( `tickets`.`title` LIKE ? OR `tickets`.`number` LIKE ? OR `ticket_articles`.`body` LIKE ? OR `ticket_articles`.`from` LIKE ? OR `ticket_articles`.`to` LIKE ? OR `ticket_articles`.`subject` LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ). joins(:articles). - limit(limit). - order('`tickets`.`created_at` DESC') + order('`tickets`.`created_at` DESC'). + limit(limit) # build result list tickets = [] diff --git a/app/models/user/search.rb b/app/models/user/search.rb index c372d8ae1..8cae405bc 100644 --- a/app/models/user/search.rb +++ b/app/models/user/search.rb @@ -57,12 +57,9 @@ returns # fallback do sql query # - stip out * we already search for *query* - query.gsub! '*', '' - users = User.find( - :all, - :limit => limit, - :conditions => ['(firstname LIKE ? or lastname LIKE ? or email LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%"], - :order => 'firstname' - ) + users = User.where( + '(firstname LIKE ? or lastname LIKE ? or email LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%", + ).order('firstname').limit(limit) return users end