Fixed load_resource "find_by" in mongoid resources

Latest versions of Mongoid supports "find_by" query, but syntax
is slightly different than Active Record.
This commit is contained in:
Alberto Bajo 2012-07-30 22:58:17 +02:00
parent b4285ae43c
commit 4a5700c07e

View File

@ -107,6 +107,8 @@ module CanCan
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