Skip to content
Snippets Groups Projects
Commit 4a5700c0 authored by Alberto Bajo's avatar Alberto Bajo
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.
parent b4285ae4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment