Skip to content

Instantly share code, notes, and snippets.

Avatar

Fran Worley fran-worley

View GitHub Profile
@fran-worley
fran-worley / .rubocop.yml
Created Apr 10, 2018
rubocop config - operation friendly(ish)
View .rubocop.yml
AllCops:
TargetRubyVersion: '2.5'
Exclude:
- 'cache/**/*'
- 'bin/*'
- 'db/**/*'
- 'test/test_helper.rb'
- '*.gemspec'
Documentation:
@fran-worley
fran-worley / input_collection.rb
Created Apr 6, 2018
input collection formular element
View input_collection.rb
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 Sep 5, 2017
ember-power-select Boostrap4.beta1
View ember-power-select.scss
// 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 Jul 28, 2017
json_api representer
View image_representer.rb
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 Mar 28, 2017
Some Reform/dry-v examples
View Example 1
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 Oct 23, 2017
A working example of nested forms just using Reform.
View _form.html.erb
#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 Jan 18, 2016
Reform/ Dry-V validation examples
View error_messages.yml
en:
errors:
rules:
title:
filled?: "can't be blank"
first_name:
filled?: "can't be blank"
last_name:
filled?: "can't be blank"
email:
You can’t perform that action at this time.