1 class DiaryEntry < ActiveRecord::Base
 
   3   belongs_to :language, :foreign_key => 'language_code'
 
   5   has_many :comments, :class_name => "DiaryComment",
 
   7                       :order => "diary_comments.id"
 
   8   has_many :visible_comments, :class_name => "DiaryComment",
 
  11                                 :users => { :visible => true },
 
  14                               :order => "diary_comments.id"
 
  16   validates_presence_of :title, :body
 
  17   validates_length_of :title, :within => 1..255
 
  18   #validates_length_of :language, :within => 2..5, :allow_nil => false
 
  19   validates_numericality_of :latitude, :allow_nil => true,
 
  20                             :greater_than_or_equal_to => -90, :less_than_or_equal_to => 90
 
  21   validates_numericality_of :longitude, :allow_nil => true,
 
  22                             :greater_than_or_equal_to => -180, :less_than_or_equal_to => 180
 
  23   validates_associated :user
 
  24   validates_associated :language