Created
August 7, 2021 08:02
-
-
Save adriangohjw/a081d63ebc10df611dfa37ab423e8a97 to your computer and use it in GitHub Desktop.
refactoring with query object
This file contains 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
class PopularSalariesQuery | |
def all | |
# return data in whatever shape is needed | |
end | |
end | |
# Somewhere in the controller | |
@data = PopularSalariesQuery.new.all |
This file contains 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
class SalaryGroup < ApplicationRecord | |
# some simple code | |
end |
This file contains 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
class SalaryGroup < ApplicationRecord | |
# some simple code | |
def self.popular_salaries | |
# return data in whatever shape is needed | |
end | |
end | |
# Somewhere in the controller | |
@data = SalaryGroup.popular_salaries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://adriangohjw.github.io/posts/2021/06/05/i-hate-fat-models-part-1-query-object.html