Created
November 26, 2020 05:50
-
-
Save jourdein/d3cb28e5f487e709ed7ca93666d6816a to your computer and use it in GitHub Desktop.
Extending Imported Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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