Browse files

Merge pull request #705 from albertobajo/mongoid_find_by

Fixed load_resource "find_by" in mongoid resources
  • Loading branch information...
2 parents cbd352c + 4a5700c commit ba82241c0a3bee59e8b607f45e42bbaf9cad8248 @ryanb committed Feb 21, 2013
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 ba82241

Please sign in to comment.