Skip to content
Browse files

Fixed load_resource "find_by" in mongoid resources

Latest versions of Mongoid supports "find_by" query, but syntax
is slightly different than Active Record.
  • Loading branch information...
1 parent b4285ae commit 4a5700c07e10b9144629f1ae63e0feb195204472 @albertobajo albertobajo committed Jul 30, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/cancan/controller_resource.rb
View
2 lib/cancan/controller_resource.rb
@@ -107,6 +107,8 @@ def find_resource
if @options[:find_by]
if resource_base.respond_to? "find_by_#{@options[:find_by]}!"
resource_base.send("find_by_#{@options[:find_by]}!", id_param)
+ elsif resource_base.respond_to? "find_by"
+ resource_base.send("find_by", { @options[:find_by].to_sym => id_param })
else
resource_base.send(@options[:find_by], id_param)
end

0 comments on commit 4a5700c

Please sign in to comment.
Something went wrong with that request. Please try again.