Skip to content

Instantly share code, notes, and snippets.

@jourdein
Created November 26, 2020 05:50
Show Gist options
  • Save jourdein/d3cb28e5f487e709ed7ca93666d6816a to your computer and use it in GitHub Desktop.
Save jourdein/d3cb28e5f487e709ed7ca93666d6816a to your computer and use it in GitHub Desktop.
Extending Imported Class
# references:
# - https://guides.rubyonrails.org/v4.0/plugins.html
# - https://stackoverflow.com/questions/22473391/custom-search-with-ransacker?rq=1
require "./app/models/investor"
Investor.class_eval do
# can directly introduce class_eval
scope :total_investment, -> { 1000+500 }
# can include module
include Extensions::Ransacker
end
module Extensions
module Ransacker
def self.included(base)
base.class_eval do
ransacker :total_investment_amount, formatter: ->(amount) {
}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment