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:
parent
b4285ae43c
commit
4a5700c07e
|
@ -107,6 +107,8 @@ module CanCan
|
||||||
if @options[:find_by]
|
if @options[:find_by]
|
||||||
if resource_base.respond_to? "find_by_#{@options[:find_by]}!"
|
if resource_base.respond_to? "find_by_#{@options[:find_by]}!"
|
||||||
resource_base.send("find_by_#{@options[:find_by]}!", id_param)
|
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
|
else
|
||||||
resource_base.send(@options[:find_by], id_param)
|
resource_base.send(@options[:find_by], id_param)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user