]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/note.rb
Use built-in form sumbit translation keys for user blocks
[rails.git] / app / models / note.rb
index b7f6928b869a75c626422b46438b81a4f7d38262..d4f9a801f41642877a0e1ca13cdb609fe11f9405 100644 (file)
@@ -2,10 +2,10 @@
 #
 # Table name: notes
 #
-#  id         :integer          not null, primary key
+#  id         :bigint(8)        not null, primary key
 #  latitude   :integer          not null
 #  longitude  :integer          not null
-#  tile       :integer          not null
+#  tile       :bigint(8)        not null
 #  updated_at :datetime         not null
 #  created_at :datetime         not null
 #  status     :enum             not null
@@ -21,7 +21,7 @@
 class Note < ActiveRecord::Base
   include GeoRecord
 
-  has_many :comments, -> { where(:visible => true).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id
+  has_many :comments, -> { left_joins(:author).where(:visible => true, :users => { :status => [nil, "active", "confirmed"] }).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id
 
   validates :id, :uniqueness => true, :presence => { :on => :update },
                  :numericality => { :on => :update, :integer_only => true }
@@ -31,8 +31,8 @@ class Note < ActiveRecord::Base
 
   validate :validate_position
 
-  scope :visible, -> { where("status != 'hidden'") }
-  scope :invisible, -> { where("status = 'hidden'") }
+  scope :visible, -> { where.not(:status => "hidden") }
+  scope :invisible, -> { where(:status => "hidden") }
 
   after_initialize :set_defaults