app/models/message_request.rb in enju_message-0.0.22 vs app/models/message_request.rb in enju_message-0.0.23
- old
+ new
@@ -1,18 +1,19 @@
require 'erubis'
class MessageRequest < ActiveRecord::Base
attr_accessible :body
- attr_accessible :sender, :receiver, :message_template, :as => :admin
+ attr_accessible :sender, :receiver, :message_template, :body, :as => :admin
scope :not_sent, where('sent_at IS NULL AND state = ?', 'pending')
scope :sent, where(:state => 'sent')
scope :started, where(:state => 'started')
belongs_to :message_template, :validate => true
belongs_to :sender, :class_name => "User", :foreign_key => "sender_id", :validate => true
belongs_to :receiver, :class_name => "User", :foreign_key => "receiver_id", :validate => true
has_many :messages
validates_associated :sender, :receiver, :message_template
- validates_presence_of :sender, :receiver, :message_template, :body
+ validates_presence_of :sender, :receiver, :message_template
+ validates_presence_of :body, :on => :update
state_machine :initial => :pending do
before_transition any - :sent => :sent, :do => :send_message
event :sm_send_message do