Add support for logical deletion of diary entries and comments.
[rails.git] / app / models / diary_entry.rb
1 class DiaryEntry < ActiveRecord::Base
2   belongs_to :user
3   belongs_to :language, :foreign_key => 'language_code'
4   
5   has_many :diary_comments, :include => :user,
6                             :conditions => {
7                               :users => { :visible => true },
8                               :visible => true
9                             },
10                             :order => "diary_comments.id"
11
12   validates_presence_of :title, :body
13   validates_length_of :title, :within => 1..255
14   #validates_length_of :language, :within => 2..5, :allow_nil => false
15   validates_numericality_of :latitude, :allow_nil => true,
16                             :greater_than_or_equal_to => -90, :less_than_or_equal_to => 90
17   validates_numericality_of :longitude, :allow_nil => true,
18                             :greater_than_or_equal_to => -180, :less_than_or_equal_to => 180
19   validates_associated :user
20   validates_associated :language
21 end