mailboxer 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  class Conversation < ActiveRecord::Base
2
- has_many :messages
2
+ has_many :messages, :dependent => :destroy
3
3
  has_many :receipts, :through => :messages
4
4
 
5
5
  validates_presence_of :subject
@@ -9,7 +9,7 @@ class Mailbox
9
9
  #Returns the notifications for the messageable
10
10
  def notifications(options = {})
11
11
  #:type => nil is a hack not to give Messages as Notifications
12
- return Notification.recipient(@messageable).where(:type => nil)
12
+ return Notification.recipient(@messageable).where(:type => nil).order("notifications.created_at DESC")
13
13
  end
14
14
 
15
15
  #Returns the conversations for the messageable
@@ -4,11 +4,14 @@ class Notification < ActiveRecord::Base
4
4
  belongs_to :sender, :polymorphic => :true
5
5
  belongs_to :object, :polymorphic => :true
6
6
  validates_presence_of :subject, :body
7
- has_many :receipts
7
+ has_many :receipts, :dependent => :destroy
8
8
 
9
9
  scope :recipient, lambda { |recipient|
10
10
  joins(:receipts).where('receipts.receiver_id' => recipient.id,'receipts.receiver_type' => recipient.class.to_s)
11
- }
11
+ }
12
+ scope :find_by_object, lambda { |object|
13
+ where('object_id' => object.id,'object_type' => object.class.to_s)
14
+ }
12
15
  scope :not_trashed, lambda {
13
16
  joins(:receipts).where('receipts.trashed' => false)
14
17
  }
@@ -10,7 +10,7 @@ module Mailboxer
10
10
  #receive notifications
11
11
  def acts_as_messageable
12
12
  has_many :messages
13
- has_many :receipts, :order => 'created_at DESC', :dependent => :delete_all
13
+ has_many :receipts, :order => 'created_at DESC', :dependent => :destroy
14
14
 
15
15
  include Mailboxer::Models::Messageable::InstanceMethods
16
16
  end
data/mailboxer.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mailboxer"
3
- s.version = "0.2.4"
3
+ s.version = "0.2.5"
4
4
  s.authors = ["Eduardo Casanova Cuesta"]
5
5
  s.summary = "Messaging system for rails apps."
6
6
  s.description = "A Rails engine that allows any model to act as messageable, permitting it interchange messages with any other messageable model." +
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailboxer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eduardo Casanova Cuesta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-04 00:00:00 +02:00
18
+ date: 2011-07-08 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency