diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 6e1738c..65dcf67 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,3 +1,7 @@ +* Fix issue when using accessible_by with nil can conditions (thanks jrallison) - see issue #66 + +* Pluralize table name for belongs_to associations in can conditions hash (thanks logandk) - see issue #62 + * Support has_many association or arrays in can conditions hash * Adding joins clause to accessible_by when conditions are across associations diff --git a/lib/cancan/can_definition.rb b/lib/cancan/can_definition.rb index c1dce1e..fc1cb0b 100644 --- a/lib/cancan/can_definition.rb +++ b/lib/cancan/can_definition.rb @@ -8,7 +8,7 @@ module CanCan @base_behavior = base_behavior @actions = [action].flatten @subjects = [subject].flatten - @conditions = conditions + @conditions = conditions || {} @block = block end diff --git a/spec/cancan/can_definition_spec.rb b/spec/cancan/can_definition_spec.rb index c9f7633..1b5f534 100644 --- a/spec/cancan/can_definition_spec.rb +++ b/spec/cancan/can_definition_spec.rb @@ -36,4 +36,9 @@ describe CanCan::CanDefinition do @conditions[:test] = 1 @can.conditions(:tableize => true).should == { :foos => { :bar => 1}, :test => 1 } end + + it "should return no association joins if conditions is nil" do + can = CanCan::CanDefinition.new(true, :read, Integer, nil, nil) + can.association_joins.should be_nil + end end