app/models/ems/report.rb in ems-0.0.8 vs app/models/ems/report.rb in ems-0.0.9

- old
+ new

@@ -1,11 +1,14 @@ module Ems class Report < ActiveRecord::Base # use friendly_id to handle our slugs extend FriendlyId friendly_id :title, use: :slugged - + def should_generate_new_friendly_id? + not self.is_live? + end + # searchable do # text :title, :stored => true # text :standfirst, :stored => true # text :content, :stored => true, :more_like_this => true do # Sanitize.clean self.content_as_html @@ -18,11 +21,11 @@ # Validators validates :slug, :presence => true, :if => :is_live? validates :category, :presence => true validates :channels, :presence => true, :if => :is_live? - validates :publish_from, :presence => true + validates :publish_from, :presence => true, :if => :is_live? validates :status, :presence => true validates :image, :attachment_presence => true, :if => :is_live? validates :title, :presence => true, :if => :is_live? validates :standfirst, :presence => true, :if => :is_live? @@ -47,11 +50,11 @@ accepts_nested_attributes_for :reports has_many :assets, :as => :assetable accepts_nested_attributes_for :assets, :allow_destroy => true # paperclip files - has_attached_file :image, :styles => { :image564x252 => "564x252#", :image312x189 => "312x189#", :image312x126 => "312x126", :image228x126 => "228x126" }.merge(PAPERCLIP_STORAGE_OPTIONS) - has_attached_file :report, :styles => { :report564x252 => "564x252#", :report312x189 => "312x189#", :report312x126 => "312x126", :report228x126 => "228x126" }.merge(PAPERCLIP_STORAGE_OPTIONS) + has_attached_file :image, { :image564x252 => "564x252#", :image312x189 => "312x189#", :image312x126 => "312x126", :image228x126 => "228x126", :path => "/ems/reports/:style/:filename" }.merge(PAPERCLIP_STORAGE_OPTIONS) + has_attached_file :report, { :report564x252 => "564x252#", :report312x189 => "312x189#", :report312x126 => "312x126", :report228x126 => "228x126", :path => "/ems/reports/:style/:filename" }.merge(PAPERCLIP_STORAGE_OPTIONS) # Method to make sure we have all our default values set on the object def init self.status ||= :draft self.content_disposition ||= :markdown