acts-as-joinable 0.1.7 → 0.1.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  spec = Gem::Specification.new do |s|
6
6
  s.name = "acts-as-joinable"
7
7
  s.authors = ["Lance Pollard"]
8
- s.version = "0.1.7"
8
+ s.version = "0.1.7.2"
9
9
  s.summary = "ActsAsJoinable: DRYing up Many-to-Many Relationships in ActiveRecord"
10
10
  s.homepage = "http://github.com/viatropos/acts-as-joinable"
11
11
  s.email = "lancejpollard@gmail.com"
@@ -1,3 +1,3 @@
1
1
  class ActsAsJoinable::Relationship < ActiveRecord::Base
2
2
  acts_as_relationship
3
- end
3
+ end
@@ -114,7 +114,7 @@ module ActsAsJoinable
114
114
  # relationship_table = `relationships`
115
115
  relationship = opposite_for(relationship)
116
116
  through_relationship = "#{relationship.to_s}_#{singular_type}_relationships".to_sym
117
- relationship_table = ActsAsJoinable::Relationship.quoted_table_name
117
+ relationship_table = ActsAsJoinable::Relationship.quoted_table_name rescue nil
118
118
 
119
119
  options.merge!(:through => through_relationship, :source => relationship, :uniq => true)
120
120
 
@@ -125,7 +125,7 @@ module ActsAsJoinable
125
125
  #if join_context == class_name.underscore
126
126
 
127
127
  # condition_string << "(#{relationship_table}.#{relationship}_type IN (?))"
128
- if join_context == class_name.underscore
128
+ if join_context == class_name.underscore# && opposite_for(relationship).to_sym != :child
129
129
  #conditions = [condition_string, [class_name]]
130
130
  else
131
131
  condition_string << "(#{relationship_table}.context IN (?))"
@@ -139,6 +139,7 @@ module ActsAsJoinable
139
139
  :class_name => "ActsAsJoinable::Relationship",
140
140
  :conditions => conditions,
141
141
  :as => opposite_for(relationship).to_sym
142
+ # :select => "#{relationship}_id, #{relationship}_type, id, #{opposite_for(relationship)}_id"
142
143
  }
143
144
 
144
145
  if association_type == :has_one
@@ -265,8 +266,12 @@ module ActsAsJoinable
265
266
  unless value.blank?
266
267
  send(plural_type) << value
267
268
  end
268
- send(plural_type).each do |object|
269
- send(plural_type).delete(object) unless (value && object.id == value.id)
269
+ if value.blank?
270
+ send(plural_type).delete_all
271
+ else
272
+ send(plural_type).each do |object|
273
+ send(plural_type).delete(object) unless (value && object.id == value.id)
274
+ end
270
275
  end
271
276
  end
272
277
  define_method "#{singular_type}_id" do
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-joinable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 95
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 7
10
- version: 0.1.7
10
+ - 2
11
+ version: 0.1.7.2
11
12
  platform: ruby
12
13
  authors:
13
14
  - Lance Pollard
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-06 00:00:00 -05:00
19
+ date: 2010-10-13 00:00:00 -05:00
19
20
  default_executable:
20
21
  dependencies: []
21
22
 
@@ -48,7 +49,7 @@ files:
48
49
  - test/test_acts_as_joinable.rb
49
50
  - test/test_helper.rb
50
51
  - app/models/relationship.rb
51
- has_rdoc: true
52
+ has_rdoc: false
52
53
  homepage: http://github.com/viatropos/acts-as-joinable
53
54
  licenses: []
54
55