Skip to content

Instantly share code, notes, and snippets.

@vlado
Created June 9, 2020 12:34
Show Gist options
  • Save vlado/ac901add83867f155748ef229b00e6dd to your computer and use it in GitHub Desktop.
Save vlado/ac901add83867f155748ef229b00e6dd to your computer and use it in GitHub Desktop.
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