Fixed some deprecation warnings
Created by: jvanbaarsen
Fixed some deprecation warnings
18 18 attr_accessible :project, :action, :data, :author_id, :project_id, 19 19 :target_id, :target_type 20 20 21 default_scope where("author_id IS NOT NULL") 21 default_scope { where.not(author_id: nil) } 80 80 # Groups 81 81 has_many :users_groups, dependent: :destroy 82 82 has_many :groups, through: :users_groups 83 has_many :owned_groups, through: :users_groups, source: :group, conditions: { users_groups: { group_access: UsersGroup::OWNER } } 84 83 has_many :owned_groups, -> { where users_groups: { group_access: UsersGroup::OWNER } }, through: :users_groups, source: :group 80 80 # Groups 81 81 has_many :users_groups, dependent: :destroy 82 82 has_many :groups, through: :users_groups 83 has_many :owned_groups, through: :users_groups, source: :group, conditions: { users_groups: { group_access: UsersGroup::OWNER } } 84 83 has_many :owned_groups, -> { where users_groups: { group_access: UsersGroup::OWNER } }, through: :users_groups, source: :group 42 42 43 43 # Relations 44 44 belongs_to :creator, foreign_key: "creator_id", class_name: "User" 45 belongs_to :group, foreign_key: "namespace_id", conditions: "type = 'Group'" 45 belongs_to :group, -> { where(type: Group) }, foreign_key: "namespace_id" 46 46 belongs_to :namespace 47 47 48 has_one :last_event, class_name: 'Event', order: 'events.created_at DESC', foreign_key: 'project_id' 48 has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id' Created by: zzet
@jvanbaarsen I think better to follow for code style guide:
has_one :last_event, -> { order(events: { created_at: :desc }) }, class_name: 'Event', foreign_key: :project_id
order(field: :type)
better thenorder field: :type
ororder 'field TYPE'
foreign_key: :project_id
better thenforeign_key: "project_id"
class_name: Event
(class_name: 'Event'.freeze
ugly) better thenclass_name: 'Event'
@randx that do you think?
By Administrator on 2013-12-09T21:26:11 (imported from GitLab project)
59 59 has_many :events, dependent: :destroy 60 60 has_many :merge_requests, dependent: :destroy, foreign_key: "target_project_id" 61 61 has_many :fork_merge_requests,dependent: :destroy, foreign_key: "source_project_id", class_name: MergeRequest 62 has_many :issues, dependent: :destroy, order: "state DESC, created_at DESC" 62 has_many :issues, -> { order "state DESC, created_at DESC" }, dependent: :destroy
Please register or sign in to reply