##// END OF EJS Templates
set default category_id instead of the object (#11665)...
set default category_id instead of the object (#11665) Rails 2.3 still has issues with synchronizing the association_id and association attributes of an object. That means, if you set the association with an object first and then just set the id afterwards, the object wins and the setting of the id gets lost. This is not an issue in Rails >= 3.1 anymore. Contributed by Holger Just. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10226 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r6676:e028e542584f
r10043:14dcefaa97f9
Show More
auto_completes_controller.rb
27 lines | 770 B | text/x-ruby | RubyLexer
/ app / controllers / auto_completes_controller.rb
Eric Davis
Refactor: move IssuesController#auto_complete to a new controller. #4382...
r3831 class AutoCompletesController < ApplicationController
before_filter :find_project
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/auto_completes_controller.rb....
r6676
Eric Davis
Refactor: move IssuesController#auto_complete to a new controller. #4382...
r3831 def issues
@issues = []
q = params[:q].to_s
Jean-Philippe Lang
Autocomplete issue relations on subject (#3170)....
r4388 query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
Eric Davis
Refactor: move IssuesController#auto_complete to a new controller. #4382...
r3831 if q.match(/^\d+$/)
Jean-Philippe Lang
Autocomplete issue relations on subject (#3170)....
r4388 @issues << query.visible.find_by_id(q.to_i)
Eric Davis
Refactor: move IssuesController#auto_complete to a new controller. #4382...
r3831 end
unless q.blank?
Jean-Philippe Lang
Autocomplete issue relations on subject (#3170)....
r4388 @issues += query.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
Eric Davis
Refactor: move IssuesController#auto_complete to a new controller. #4382...
r3831 end
Jean-Philippe Lang
Make sure there's no nil result in auto_complete....
r4389 @issues.compact!
Eric Davis
Refactor: move IssuesController#auto_complete to a new controller. #4382...
r3831 render :layout => false
end
private
def find_project
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
@project = Project.find(project_id)
rescue ActiveRecord::RecordNotFound
render_404
end
end