Last active
February 3, 2017 14:35
-
-
Save Aerlinger/ba8fe98fb58ec6be4d6f to your computer and use it in GitHub Desktop.
Revisions
-
Aerlinger renamed this gist
Oct 21, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Aerlinger revised this gist
Oct 21, 2014 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ 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 end -
Aerlinger created this gist
Oct 21, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ def 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