X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a41d500b9f65ec9f4e848effd38dc1ae117e7594..c37dc5c56d4be881e44500e1c8dde1826c0f78a7:/app/models/changeset_comment.rb diff --git a/app/models/changeset_comment.rb b/app/models/changeset_comment.rb index ceb7d3559..09eabe893 100644 --- a/app/models/changeset_comment.rb +++ b/app/models/changeset_comment.rb @@ -3,15 +3,18 @@ # Table name: changeset_comments # # id :integer not null, primary key -# changeset_id :bigint(8) not null -# author_id :bigint(8) not null +# changeset_id :bigint not null +# author_id :bigint not null # body :text not null # created_at :datetime not null # visible :boolean not null # # Indexes # -# index_changeset_comments_on_created_at (created_at) +# index_changeset_comments_on_author_id_and_created_at (author_id,created_at) +# index_changeset_comments_on_author_id_and_id (author_id,id) +# index_changeset_comments_on_changeset_id_and_created_at (changeset_id,created_at) +# index_changeset_comments_on_created_at (created_at) # # Foreign Keys # @@ -23,10 +26,12 @@ class ChangesetComment < ApplicationRecord belongs_to :changeset belongs_to :author, :class_name => "User" + scope :visible, -> { where(:visible => true) } + validates :id, :uniqueness => true, :presence => { :on => :update }, :numericality => { :on => :update, :only_integer => true } - validates :changeset, :presence => true, :associated => true - validates :author, :presence => true, :associated => true + validates :changeset, :associated => true + validates :author, :associated => true validates :visible, :inclusion => [true, false] validates :body, :characters => true