Skip to content

Instantly share code, notes, and snippets.

View zernie's full-sized avatar
🏠
Working from home

zernie zernie

🏠
Working from home
View GitHub Profile
def flatten(array)
array.reduce([]) do |sum, n|
sum + (n.kind_of?(Array) ? flatten(n) :[n])
end
end
p flatten([[1,2,[3]],4])
module FormObjectHelpers
extend ActiveSupport::Concern
included do
def form(klass, attributes = {}, options = {})
form = klass.new(current_user, params, attributes)
authorize_model(form, options)
yield form if block_given?
render action_name, locals: { form: form }
require 'ostruct'
class BaseForm
include ActiveModel::Model
attr_reader :attributes,
:attributes_hash,
:current_user,
:params,
:params_hash,
:model
cloc . --exclude-dir=node_modules,tmp,webpack,vendor,cookbooks,public,log