X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d74d4f8d195673250c3f2e841d28f185d74d8849..15a7276a9f50821a7728b4da3af16849284f251b:/app/models/note.rb?ds=sidebyside diff --git a/app/models/note.rb b/app/models/note.rb index 10b74d8a6..27357e58a 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -1,10 +1,7 @@ class Note < ActiveRecord::Base include GeoRecord - has_many :comments, :class_name => "NoteComment", - :foreign_key => :note_id, - :order => :created_at, - :conditions => { :visible => true } + has_many :comments, -> { where(:visible => true).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id validates_presence_of :id, :on => :update validates_uniqueness_of :id @@ -14,7 +11,8 @@ class Note < ActiveRecord::Base validates_inclusion_of :status, :in => ["open", "closed", "hidden"] validate :validate_position - attr_accessible :lat, :lon + scope :visible, -> { where("status != 'hidden'") } + scope :invisible, -> { where("status = 'hidden'") } after_initialize :set_defaults