Skip to content

Instantly share code, notes, and snippets.

View fran-worley's full-sized avatar

Fran Worley fran-worley

View GitHub Profile
@fran-worley
fran-worley / .rubocop.yml
Created April 10, 2018 07:54
rubocop config - operation friendly(ish)
AllCops:
TargetRubyVersion: '2.5'
Exclude:
- 'cache/**/*'
- 'bin/*'
- 'db/**/*'
- 'test/test_helper.rb'
- '*.gemspec'
Documentation:
@fran-worley
fran-worley / input_collection.rb
Created April 6, 2018 11:11
input collection formular element
require 'formular/elements'
class InputCollection < Input
set_default :include_hidden, true
html do |element|
concat element.collection.map { |item|
item.to_html(context: :default)
}.join('')
concat element.hidden_tag
end
@fran-worley
fran-worley / ember-power-select.scss
Created September 5, 2017 16:01
ember-power-select Boostrap4.beta1
// Variables
// Backgrounds
$ember-power-select-background-color: #ffffff !default;
$ember-power-select-disabled-background-color: #eeeeee !default;
$ember-power-select-multiple-selection-background-color: $gray-200 !default;
$ember-power-select-highlighted-background: $blue !default;
$ember-power-select-selected-background: $gray-200 !default;
// Texts
@fran-worley
fran-worley / image_representer.rb
Last active July 28, 2017 10:15
json_api representer
require 'image/persistence'
class Image
class Representer < Roar::Decorator
include Roar::JSON::JSONAPI.resource :images
# top-level link.
link :self, toplevel: true do
"//images"
end
attributes do
@fran-worley
fran-worley / Example 1
Last active March 28, 2017 19:42
Some Reform/dry-v examples
class FieldForm < Reform::Form
property :key
collection :field_options, form: FieldOptionForm
validation do
configure do
option :form # include this line if you want access to your form in predicates
config.messages_file = 'config/error_messages.yml' # if you define any custom predicates you must provide a message for them
@fran-worley
fran-worley / _form.html.erb
Last active October 23, 2017 23:42
A working example of nested forms just using Reform.
#views/users/_form.html.erb
<%= simple_form_for @form do |f| %>
<%= f.error_notification %>
<%= f.input :name %>
<%= f.input :email %>
<h4>
<%= link_to_add_fields icon(:plus),
@fran-worley
fran-worley / error_messages.yml
Last active April 18, 2021 08:25
Reform/ Dry-V validation examples
en:
errors:
rules:
title:
filled?: "can't be blank"
first_name:
filled?: "can't be blank"
last_name:
filled?: "can't be blank"
email: