Skip to content

Instantly share code, notes, and snippets.

View pama's full-sized avatar

Paulo Abreu pama

View GitHub Profile
@pama
pama / controller.rb
Last active March 16, 2022 12:20
Search model example
class Cligest::DocumentsController < ApplicationController
# ...
def index
@document_search = DocumentSearch.new(document_search_params)
@documents = @document_search.perform
# perhaps a few more initializations
respond_to do |format|
@pama
pama / controller.rb
Last active March 16, 2022 12:18
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 .....
<%= turbo_stream.update "panel" do %>
<% if params[:position].to_i <= 5 %>
<p>Less or equal to 5</p>
<% else %>
<p>more than 5</p>
<% end %>
<% end %>