Skip to content
This repository has been archived by the owner on Sep 15, 2020. It is now read-only.

Commit

Permalink
Fixed load_resource "find_by" in mongoid resources
Browse files Browse the repository at this point in the history
Latest versions of Mongoid supports "find_by" query, but syntax
is slightly different than Active Record.
  • Loading branch information
albertobajo committed Jul 30, 2012
1 parent b4285ae commit 4a5700c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/cancan/controller_resource.rb
Expand Up @@ -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
Expand Down

0 comments on commit 4a5700c

Please sign in to comment.