1 class Issue < ActiveRecord::Base
4 before_destroy { |issue| Permalink.destroy_all "issue_id = '#{issue.id}'" }
7 belongs_to :created_by, :class_name => "User", :foreign_key => "created_by"
9 has_many :comments, :dependent => :destroy, :order => "comments.created_at ASC"
10 has_many :all_permalnks, :class_name => "Permalink", :foreign_key => "issue_id", :dependent => :destroy
12 has_many :attachments, :class_name => "Attachment", :foreign_key => "issue_id", :dependent => :destroy
14 validates_presence_of :title, :description
17 self.created_at.year()
21 self.created_at.strftime("%m") # month() with leading zero
25 self.created_at.strftime("%d") # day() with leading zero
28 # FIXME: we should be checking that the title has changed significantly, not just that it has been edited
30 write_attribute(:title, new_title)
35 def create_permalink()
36 return if self.id.nil?
37 self.permalink = Permalink.create( { :link_name => self.title, :issue_id => self.id } )