app/models/message_request.rb in enju_message-0.0.21 vs app/models/message_request.rb in enju_message-0.0.22

- old
+ new

@@ -1,9 +1,9 @@ require 'erubis' class MessageRequest < ActiveRecord::Base attr_accessible :body - attr_accessible :sender, :receiver, :message_template, :sent_at, :as => :admin + attr_accessible :sender, :receiver, :message_template, :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 @@ -40,10 +40,11 @@ if self.body message = Message.create!(:sender => self.sender, :recipient => self.receiver.username, :subject => self.subject, :body => self.body) else raise 'body is empty!' end - self.update_attributes({:sent_at => Time.zone.now}) + self.sent_at = Time.zone.now + save! if ['reservation_expired_for_patron', 'reservation_expired_for_patron'].include?(self.message_template.status) self.receiver.reserves.each do |reserve| reserve.update_attribute(:expiration_notice_to_patron, true) end end