Version: 1.9.8
Platform: x86_64
First, install or update to the latest system software.
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
module FactoryGirl::Syntax::Methods | |
def find_or_create(name, attributes = {}, &block) | |
factory = FactoryGirl.factory_by_name(name) | |
clazz = factory.build_class | |
factory_attributes = FactoryGirl.attributes_for(name) | |
attributes = factory_attributes.merge(attributes) | |
clazz.find_or_create_by(attributes, &block) | |
end |
module FactoryGirl | |
def self.find_or_create(resource_name, attributes = {}, &block) | |
clazz = resource_name.to_s.classify.constantize | |
model = clazz.find_by(attributes) || FactoryGirl.build(resource_name, attributes) | |
yield(model) if block_given? && model.new_record? | |
model.tap(&:save) | |
end |
# first we create an empty ActiveRecord::Relation object | |
relation = Model.where(attribute: value) | |
# then we make the relation stub the :[] method | |
# and return whatever values we need | |
relation.stub(:[]).and_return( Model.new({attrs: values})] ) | |
# of course, we can make this too | |
# instead of the step above | |
record = double("Model", :foo => 'bar', :bar => 'baz') |
# .railsrc | |
-B #Skip Bundle | |
-T #Skip Test-Unit | |
-d postgresql #Use postgres |
Ripped off from adrianshort.org
$ git remote -v
origin https://github.com/hakimel/reveal.js.git (fetch)
origin https://github.com/hakimel/reveal.js.git (push)
$.fn.parsley.defaults = { | |
// basic data-api overridable properties here.. | |
inputs: 'input, textarea, select' // Default supported inputs. | |
, excluded: 'input[type=hidden], :disabled' // Do not validate input[type=hidden] & :disabled. | |
, trigger: false // $.Event() that will trigger validation. eg: keyup, change.. | |
, animate: true // fade in / fade out error messages | |
, animateDuration: 300 // fadein/fadout ms time | |
, focus: 'first' // 'fist'|'last'|'none' which error field would have focus first on form validation | |
, validationMinlength: 3 // If trigger validation specified, only if value.length > validationMinlength | |
, successClass: 'has-success' // Class name on each valid input |
json = ActiveSupport::JSON.decode(File.read('db/seeds/countries.json')) | |
json.each do |a| | |
Country.create!(a['country'], without_protection: true) | |
end |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
require 'active_support' | |
class Foo | |
def foo | |
"foo" | |
end | |
def bar | |
ActiveSupport::Deprecation.warn("bar is deprecated") |