Skip to content

Commit df5b6eb

Browse files
committed
Allow Marshal.dump on objects that only have polymorphic associations where a polymorphic association is loaded
Was incorrectly matching to _dump
1 parent 46b51fc commit df5b6eb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/searchlogic/named_scopes/association_conditions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def association_condition_details(name, last_condition = nil)
3232
poly_type = nil
3333
condition = nil
3434

35-
if name_with_condition.to_s =~ /^(#{non_poly_assocs.collect(&:name).join("|")})_(\w+)$/
35+
if name_with_condition.to_s =~ /^(#{non_poly_assocs.collect(&:name).join("|")})_(\w+)$/ && non_poly_assocs.present?
3636
association_name = $1
3737
condition = $2
3838
elsif name_with_condition.to_s =~ /^(#{poly_assocs.collect(&:name).join("|")})_(\w+?)_type_(\w+)$/

spec/searchlogic/named_scopes/association_conditions_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,10 @@
217217
user.orders.id_equals(order1.id).count.should == 1
218218
user.orders.id_equals(order1.id).total_equals(2).count.should == 1
219219
end
220+
221+
it "should allow Marshal.dump on objects that only have polymorphic associations where a polymorphic association is loaded" do
222+
audit = Audit.create
223+
audit.auditable = User.create
224+
lambda { Marshal.dump(audit) }.should_not raise_error
225+
end
220226
end

0 commit comments

Comments
 (0)