lib/wpb/pagepost.rb in wpb-0.0.2 vs lib/wpb/pagepost.rb in wpb-0.0.3

- old
+ new

@@ -3,26 +3,50 @@ class PagePost < ActiveRecord::Base set_table_name :wp_posts set_primary_key :ID before_save :update_date + before_create :set_default_values + validates_presence_of :post_author + + has_many :comments, :foreign_key => :comment_post_ID + + def set_default_values + t = Time.now + self.post_date = t + self.post_date_gmt = t.gmtime + + # Ready for when Site model is added + # site_url = Site.find_by_option_name "siteurl" + # type = 'p' + # if self.type == "Page" + # type << 'age_id' + # end + # self.guid = "#{site_url}/?#{type}=#{self.id}" + + urlify = self.post_title.dup.downcase.gsub(' ', '-') + self.post_name = urlify + end + def update_date - #TODO: update date_modified column + t = Time.now + self.post_modified = t + self.post_modified_gmt = t.gmtime end def title post_title end def title= new_title - post_title = new_title + self.post_title = new_title end - def body + def content post_content end - def body= new_content - post_content = new_content + def content= new_content + self.post_content = new_content end end \ No newline at end of file