Moved to rails 4.1.

This commit is contained in:
Martin Edenhofer 2014-05-20 21:49:48 +02:00
parent 9841ce75e5
commit 3b766c81cf
4 changed files with 14 additions and 23 deletions

View file

@ -1,6 +1,6 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'rails', '4.0.3' gem 'rails', '4.1.0'
gem 'rails-observers' gem 'rails-observers'
gem 'activerecord-session_store' gem 'activerecord-session_store'
@ -14,8 +14,8 @@ gem 'json'
# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.
group :assets do group :assets do
gem 'sass-rails', '~> 4.0.1' gem 'sass-rails'
gem 'coffee-rails', '~> 4.0.1' gem 'coffee-rails'
gem 'uglifier' gem 'uglifier'
end end

View file

@ -41,21 +41,15 @@ returns
# fallback do sql query # fallback do sql query
# - stip out * we already search for *query* - # - stip out * we already search for *query* -
query.gsub! '*', '' query.gsub! '*', ''
organizations = Organization.find( organizations = Organization.where(
:all, 'name LIKE ? OR note LIKE ?', "%#{query}%", "%#{query}%"
:limit => limit, ).order('name').limit(limit)
:conditions => ['name LIKE ? OR note LIKE ?', "%#{query}%", "%#{query}%"],
:order => 'name'
)
# if only a few organizations are found, search for names of users # if only a few organizations are found, search for names of users
if organizations.length <= 3 if organizations.length <= 3
organizations_by_user = Organization.select('DISTINCT(organizations.id)').joins('LEFT OUTER JOIN users ON users.organization_id = organizations.id').find( organizations_by_user = Organization.select('DISTINCT(organizations.id)').joins('LEFT OUTER JOIN users ON users.organization_id = organizations.id').where(
:all, 'users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?', "%#{query}%", "%#{query}%", "%#{query}%"
:limit => limit, ).order('organizations.name').limit(limit)
:conditions => ['users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?', "%#{query}%", "%#{query}%", "%#{query}%"],
:order => 'organizations.name'
)
organizations_by_user.each {|organization_by_user| organizations_by_user.each {|organization_by_user|
organization_exists = false organization_exists = false
organizations.each {|organization| organizations.each {|organization|

View file

@ -91,8 +91,8 @@ returns
where(conditions). 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}%" ). 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). joins(:articles).
limit(limit). order('`tickets`.`created_at` DESC').
order('`tickets`.`created_at` DESC') limit(limit)
# build result list # build result list
tickets = [] tickets = []

View file

@ -57,12 +57,9 @@ returns
# fallback do sql query # fallback do sql query
# - stip out * we already search for *query* - # - stip out * we already search for *query* -
query.gsub! '*', '' query.gsub! '*', ''
users = User.find( users = User.where(
:all, '(firstname LIKE ? or lastname LIKE ? or email LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%",
:limit => limit, ).order('firstname').limit(limit)
:conditions => ['(firstname LIKE ? or lastname LIKE ? or email LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%"],
:order => 'firstname'
)
return users return users
end end