- 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 = {} |
# 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
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.
export function transitionIn (el, show = () => {}) { | |
const attrs = getXAttrs(el, 'transition') | |
// If any transition attrs. | |
if (attrs.filter(attr => ['enter', 'enter-start', 'enter-end'].includes(attr.value)).length > 0) { | |
transitionClassesIn(el, attrs, show) | |
} else { | |
// If not, just show that damn thing. | |
show() | |
} |
<div class="mt-6"> | |
<%= f.label :tags, class: 'form-label' %> | |
<div class="border border-gray-300 rounded-md flex-1 block w-full transition duration-150 ease-in-out pt-1.5 px-2 mt-1" data-controller="tags" data-tags-tag-collection data-tags-autocomplete="true" data-tags-show-dropdown="" data-target="tags.container"> | |
<div class="flex flex-wrap cursor-text" data-action="click->tags#active"> | |
<div class="flex flex-wrap" data-target="tags.tags"> | |
<div class="text-sm p-2 bg-gray-100 rounded-md flex items-center space-x-1.5 mb-1.5 mr-2"> | |
<p>tag</p> | |
<div class="inline-flex bg-gray-500 text-gray-100 rounded-full p-1 hover:bg-gray-700 cursor-pointer"> | |
<svg class="h-3 w-3" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M6 18L18 6M6 6l12 12"></path></ |
This is a complete, step-by-step tutorial showing how to create a fully functional contact form in production in rails 5. Rather than reinvent things, the following borrows from the best available documentation and tutorials (most notably, this tutorial on making a contact form in development). The finished contact form can be viewed here.
This tutorial uses:
It would be a good idea to create a new gmail account to use for your mailer now, if you haven't already. If you haven't yet got a heroku account and installed the heroku CLI, it would be easiest to do so now.