New features and how we can use them in existing applications
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
import {Controller} from "@hotwired/stimulus" | |
import {debounce} from "lodash/function"; | |
// Connects to data-controller="auto-save" | |
export default class extends Controller { | |
initialize() { | |
this.autosave = debounce(this.autosave, 200).bind(this) | |
} | |
autosave(event) { |
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
def active_link_to(name = nil, options = nil, **html_options, &block) | |
options = block_given? ? name : options | |
if current_page?(options) | |
html_options[:class] = class_names(html_options[:class], :active) | |
html_options[:aria] = html_options.fetch(:aria, {}).merge(current: :page) | |
end | |
if block_given? | |
link_to options, html_options, &block |
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
module TurboFrameHelpers | |
def turbo_frame_id(*ids) | |
ids.map { |id| id.respond_to?(:to_key) ? ActionView::RecordIdentifier.dom_id(id) : id }.join("_") | |
end | |
end | |
RSpec.configure do |config| | |
config.include TurboFrameHelpers | |
end |
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
require 'capybara' |
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
ruby 3.0.1 | |
nodejs 16.0.0 |
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
web: bundle exec rails server | |
worker: bundle exec sidekiq | |
webpack: bundle exec bin/webpack-dev-server |
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
# Stop Google's FLoc https://andycroll.com/ruby/opt-out-of-google-floc-tracking-on-netlify | |
[[headers]] | |
for = "/*" | |
[headers.values] | |
Permissions-Policy = "interest-cohort=()" |
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
<script> | |
// Declaring a new jQuery function | |
(function ($) { | |
$.fn.newSuperCoolFunction = function () { | |
return this.each(function (_, selector) { | |
var elements = $(selector) | |
elements.each(function (_, elementSelector) { | |
var element = $(elementSelector); | |
element.addClass('super-cool') |
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
# FizzBuzz | |
def add_trigger_word(number, factor, output_array, word) | |
output_array << word if number % factor == 0 | |
output_array | |
end | |
word_map = { | |
3 => "Fizz", | |
5 => "Buzz", |
NewerOlder