Skip to content

Instantly share code, notes, and snippets.

@tabishiqbal
tabishiqbal / _form.html.erb
Last active October 16, 2024 20:39
Ruby on Rails Tom-Select Example with Stimulus controller
<%= form_with(model: team) do |form| %>
<div>
<%= form.label :name %>
<%= form.text_field :name, class: "input" %>
</div>
<div>
<%= f.select :user_id, {}, {placeholder: "Select user"}, {class: "w-full", data: { controller: "select", select_url_value: users_path }} %>
</div>
@obie
obie / _search.haml
Created November 5, 2020 01:24
Search Implementation using stimulus, shoelace, and mark.js
.spreadsheet--search.grid.grid-flow-col.grid-cols-auto.gap-0.auto-cols-fr.pl-1.pr-8.hidden{ data: { controller: "spreadsheet--search", action: "toggle-search@window->spreadsheet--search#toggleSearch" }}
.input.col-span-9.p-2
%sl-input.w-full(placeholder="Search" size="small" clearable pill){ data: { target: "spreadsheet--search.input"}}
%sl-icon(name="search" slot="prefix")
%sl-dropdown(slot="suffix" placement="bottom-end" hoist){ data: { target: "spreadsheet--search.dropdown"}}
%sl-button(slot="trigger" caret type="text" size="small"){ data: { target: "spreadsheet--search.trigger"}} Highlight
%sl-menu
%sl-menu-item{ data: { target: "spreadsheet--search.higlight"}, checked: true} Highlight
%sl-menu-item{ data: { target: "spreadsheet--search.filter"}} Filter
@ftes
ftes / _seating_plan.html.haml
Created November 20, 2019 21:26
Drag and drop in CSS grid with rails 6, stimulus and rails-ujs
-# https://johnbeatty.co/2018/03/09/stimulus-js-tutorial-how-do-i-drag-and-drop-items-in-a-list/
.grid--draggable{ 'data-controller': 'seating-plan',
'data-seating-plan-endpoint': endpoint,
'data-action': 'dragstart->seating-plan#onDragStart dragover->seating-plan#onDragOver dragenter->seating-plan#onDragEnter drop->seating-plan#onDrop dragend->seating-plan#onDragEnd' }
- seating_plan.each do |seat|
- if seat[:is_empty]
.grid__item.grid__item--empty{ 'data-row': seat[:row],
'data-col': seat[:col],
style: "grid-row: #{seat[:row]}; grid-column: #{seat[:col]};",
class: ('grid__item--border' if seat[:is_border]) }
@ndbroadbent
ndbroadbent / Gemfile
Last active December 11, 2021 22:31
How to get accurate SimpleCov coverage with Spring in a Rails application
group :development, :test do
gem 'spring-commands-rspec', require: false
gem 'spring-watcher-listen', require: false
gem 'spring', require: false
# ...
end
@jgrodziski
jgrodziski / docker-aliases.sh
Last active November 9, 2024 17:50
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #
@johnmeehan
johnmeehan / _modal.html.haml
Last active February 14, 2023 19:20
Rails + Reform + Bootstrap + Ajax Modal Form
# simple_form Reform Form for creating a basic postal address
# errors will be shown on the violating fields
= simple_form_for(@form, remote: true) do |f|
.modal-dialog
.modal-content
.modal-header
%button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
%h3.modal-title
New Address for
= @customer.name
@bettysteger
bettysteger / trix_editor.css
Last active April 10, 2020 07:23
Trix Editor Toolbar Icons with FontAwesome
trix-toolbar .button_group button::before {
background-image: none !important;
font-family: 'FontAwesome';
font-size: 12px;
line-height: 28px;
}
trix-toolbar .button_group button.bold:before {
content: '\f032';
}
@maxivak
maxivak / readme.md
Last active January 12, 2024 06:53
Integrating Gem/Engine and Main Rails App
@mpetroff
mpetroff / index.html
Created March 28, 2015 02:29
Bootstrap Navbar without jQuery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Navbar Template for Bootstrap</title>
@bigglesrocks
bigglesrocks / README.md
Last active February 24, 2023 05:51
Rails Scoped Invitation System

#Scoped Invitation System for User Groups with Rails#

Starting out with the following models and associations:

####User

  • has_many :memberships
  • has_many :organizations through :memberships

####Organization (User Group)

  • has_many :memberships