- Setup Shrine:
First, add the Shrine gem to your application's Gemfile
:
class AttachedValidator < ActiveModel::EachValidator | |
# Active Storage validator to ensure that an attachment is attached. | |
# | |
# usage: | |
# validates :upload, attached: true | |
# | |
def validate_each(record, attribute, _value) | |
return if record.send(attribute).attached? | |
errors_options = {} |
<%= form_with(model: product) do |form| %> | |
<div> | |
<%= form.label :name %> | |
<%= form.text_field :name, class: "input" %> | |
</div> | |
<div> | |
<%= form.label :categories %> | |
<%= form.collection_select :category_ids, Category.all, :id, :name, {}, {multiple: true, id: 'category-select', class: "dropdown"} %> | |
</div> |
# frozen_string_literal: true | |
module Slug | |
extend ActiveSupport::Concern | |
def self.included(base) | |
base.extend ClassMethods | |
base.before_create :set_slug | |
end | |
def to_param |
Gemfile.lock merge=bundlelock | |
db/schema.rb merge=railsschema |
Dataclips has a reliable way to construct the URL of a clip's CSV version:
https://dataclips.heroku.com/<hash>-<description>.csv
Thankfully the description is irrelevant, so we can just get the hash from the web interface
(looks like aujqawhjdmlbbwrqxutcpzzqyika
) and add -1
at the end. Every time we change the
<%= 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> |
class RegionReflex < ApplicationReflex | |
def select_state | |
state_id = element[:value].to_i | |
@state = State.find(state_id) | |
@state_cities = @state&.cities | |
end | |
end |
class CategoriesController < ApplicationController | |
def fields | |
render json: Field.where(category_id: params[:id]).order(:id) | |
end | |
end |
https://joshuajohnson.co.uk/Choices/
Soon, this will be published as an NPM package, but there's an absence of documentation right now. It supports almost all functions from the original library; soon it will support 100% of them.
This wrapper adds Ajax pre-fetch search. Happens if controller has a data-search-path
attribute.
Stimulus controller targets use new v2 syntax. Controller attaches a reference to itself on the element so that you can access the internal state from external scripts.