Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created May 16, 2013 13:31
Show Gist options
  • Save mikecmpbll/5591748 to your computer and use it in GitHub Desktop.
Save mikecmpbll/5591748 to your computer and use it in GitHub Desktop.
# app/decorators/models/my_engine/user_decorator.rb
MyEngine::User.class_eval do
def self.find_by_name str
where("CONCAT(#{table_name}.firstname, ' ', #{table_name}.surname) LIKE :s", { s: "%#{str}%" })
end
end
# rails c
MyEngine::User.find_by_name "John"
NoMethodError: undefined method `find_by_name' for #<Class:0x007fcb85a45580>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment