can :read, [:deletion, :account_terms, :account_pd_declaration, :account_home]
if Settings.status != "database_offline"
- can [:read, :create, :destroy], :changeset_subscription
+ can [:read, :create, :destroy], ChangesetSubscription
can [:read, :create, :update, :destroy], :oauth2_application
can [:read, :destroy], :oauth2_authorized_application
can [:read, :create, :destroy], :oauth2_authorization
before_action :set_locale
before_action :check_database_writable
- authorize_resource :class => :changeset_subscription
+ authorize_resource
around_action :web_timeout
has_many :old_relations
has_many :comments, -> { where(:visible => true).order(:created_at) }, :class_name => "ChangesetComment"
- has_and_belongs_to_many :subscribers, :class_name => "User", :join_table => "changesets_subscribers", :association_foreign_key => "subscriber_id"
+ has_many :subscriptions, :class_name => "ChangesetSubscription"
+ has_many :subscribers, :through => :subscriptions
validates :id, :uniqueness => true, :presence => { :on => :update },
:numericality => { :on => :update, :only_integer => true }
--- /dev/null
+# == Schema Information
+#
+# Table name: changesets_subscribers
+#
+# subscriber_id :bigint not null
+# changeset_id :bigint not null
+#
+# Indexes
+#
+# index_changesets_subscribers_on_changeset_id (changeset_id)
+# index_changesets_subscribers_on_subscriber_id_and_changeset_id (subscriber_id,changeset_id) UNIQUE
+#
+# Foreign Keys
+#
+# changesets_subscribers_changeset_id_fkey (changeset_id => changesets.id)
+# changesets_subscribers_subscriber_id_fkey (subscriber_id => users.id)
+#
+class ChangesetSubscription < ApplicationRecord
+ self.table_name = "changesets_subscribers"
+
+ belongs_to :subscriber, :class_name => "User"
+ belongs_to :changeset
+end
has_many :preferences, :class_name => "UserPreference"
has_many :changesets, -> { order(:created_at => :desc) }, :inverse_of => :user
has_many :changeset_comments, :foreign_key => :author_id, :inverse_of => :author
- has_and_belongs_to_many :changeset_subscriptions, :class_name => "Changeset", :join_table => "changesets_subscribers", :foreign_key => "subscriber_id"
+ has_many :changeset_subscriptions, :foreign_key => :subscriber_id
has_many :note_comments, :foreign_key => :author_id, :inverse_of => :author
has_many :notes, :through => :note_comments
has_many :note_subscriptions, :class_name => "NoteSubscription"