Created
June 9, 2020 12:34
-
-
Save vlado/ac901add83867f155748ef229b00e6dd to your computer and use it in GitHub Desktop.
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 SearchForm | |
include ActiveModel::Model | |
%i[query lat lng].each do |name| | |
define_method name do | |
@params[name] | |
end | |
end | |
def initialize(params) | |
@params = params | |
end | |
end | |
# Usage in controller | |
# @search_form = SearchForm.new(params.permit(:query, :lat, :lng)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment