class Attachment < ActiveRecord::Base
belongs_to :container, :polymorphic => true
- belongs_to :author, :class_name => "User", :foreign_key => "author_id"
+ belongs_to :author, :class_name => "User"
validates_presence_of :filename, :author
validates_length_of :filename, :maximum => 255
belongs_to :project
has_many :topics, lambda {where("#{Message.table_name}.parent_id IS NULL").order("#{Message.table_name}.created_on DESC")}, :class_name => 'Message'
has_many :messages, lambda {order("#{Message.table_name}.created_on DESC")}, :dependent => :destroy
- belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
+ belongs_to :last_message, :class_name => 'Message'
acts_as_tree :dependent => :nullify
acts_as_list :scope => '(project_id = #{project_id} AND parent_id #{parent_id ? "= #{parent_id}" : "IS NULL"})'
acts_as_watchable
class Comment < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :commented, :polymorphic => true, :counter_cache => true
- belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
+ belongs_to :author, :class_name => 'User'
validates_presence_of :commented, :author, :comments
attr_protected :id
class Document < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project
- belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
+ belongs_to :category, :class_name => "DocumentCategory"
acts_as_attachable :delete_permission => :delete_documents
acts_as_searchable :columns => ['title', "#{table_name}.description"],
belongs_to :project
belongs_to :tracker
- belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
- belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
- belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
- belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
- belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id'
- belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
+ belongs_to :status, :class_name => 'IssueStatus'
+ belongs_to :author, :class_name => 'User'
+ belongs_to :assigned_to, :class_name => 'Principal'
+ belongs_to :fixed_version, :class_name => 'Version'
+ belongs_to :priority, :class_name => 'IssuePriority'
+ belongs_to :category, :class_name => 'IssueCategory'
has_many :journals, :as => :journalized, :dependent => :destroy
has_many :visible_journals,
class IssueCategory < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project
- belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
+ belongs_to :assigned_to, :class_name => 'Principal'
has_many :issues, :foreign_key => 'category_id', :dependent => :nullify
validates_presence_of :name
end
end
- belongs_to :issue_from, :class_name => 'Issue', :foreign_key => 'issue_from_id'
- belongs_to :issue_to, :class_name => 'Issue', :foreign_key => 'issue_to_id'
+ belongs_to :issue_from, :class_name => 'Issue'
+ belongs_to :issue_to, :class_name => 'Issue'
TYPE_RELATES = "relates"
TYPE_DUPLICATES = "duplicates"
class Message < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :board
- belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
+ belongs_to :author, :class_name => 'User'
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
acts_as_attachable
- belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
+ belongs_to :last_reply, :class_name => 'Message'
attr_protected :id
acts_as_searchable :columns => ['subject', 'content'],
class News < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project
- belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
+ belongs_to :author, :class_name => 'User'
has_many :comments, lambda {order("created_on")}, :as => :commented, :dependent => :delete_all
validates_presence_of :title, :description
belongs_to :project
belongs_to :issue
belongs_to :user
- belongs_to :activity, :class_name => 'TimeEntryActivity', :foreign_key => 'activity_id'
+ belongs_to :activity, :class_name => 'TimeEntryActivity'
attr_protected :user_id, :tyear, :tmonth, :tweek
class WikiContent < ActiveRecord::Base
self.locking_column = 'version'
- belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
- belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
+ belongs_to :page, :class_name => 'WikiPage'
+ belongs_to :author, :class_name => 'User'
validates_presence_of :text
validates_length_of :comments, :maximum => 255, :allow_nil => true
attr_protected :id
end
class Version
- belongs_to :page, :class_name => '::WikiPage', :foreign_key => 'page_id'
- belongs_to :author, :class_name => '::User', :foreign_key => 'author_id'
+ belongs_to :page, :class_name => '::WikiPage'
+ belongs_to :author, :class_name => '::User'
attr_protected :data
acts_as_event :title => Proc.new {|o| "#{l(:label_wiki_edit)}: #{o.page.title} (##{o.version})"},
belongs_to :role
belongs_to :tracker
- belongs_to :old_status, :class_name => 'IssueStatus', :foreign_key => 'old_status_id'
- belongs_to :new_status, :class_name => 'IssueStatus', :foreign_key => 'new_status_id'
+ belongs_to :old_status, :class_name => 'IssueStatus'
+ belongs_to :new_status, :class_name => 'IssueStatus'
validates_presence_of :role, :tracker, :old_status
attr_protected :id