Skip to content

Instantly share code, notes, and snippets.

@pama
Last active March 16, 2022 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pama/ea8774d10d9efb61ddd745fa93c637d2 to your computer and use it in GitHub Desktop.
Save pama/ea8774d10d9efb61ddd745fa93c637d2 to your computer and use it in GitHub Desktop.
Search example using query chain
# build a form that posts a document (or whatever) and the form must have the starts_at and ends_at attributes
# you might need to adjust the attributes
@documents = Document.all
# if we have the params
@documents = @document.where(referenced_at: params[:document][:starts_at]..params[:document][:ends_at]) if .....
<!-- https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-date_select -->
<%= form_tag documents_path %>
<label>from</label>
<%= date_select :document, :starts_at %>
<label>to</label>
<%= date_select :document, :endts_at %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment