Created
July 19, 2011 20:44
-
-
Save metaskills/1093662 to your computer and use it in GitHub Desktop.
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 characters
| class Merchant < ActiveRecord::Base | |
| def foobarable? | |
| # ... | |
| end | |
| end | |
| class Customer < ActiveRecord::Base | |
| belongs_to :merchant | |
| def foobar=(something_else) | |
| self[:foobar] = something_else if merchant.foobarable? | |
| end | |
| end | |
| FactoryGirl.define do | |
| factory :merchant do | |
| end | |
| factory :customer do | |
| association :merchant | |
| end | |
| end | |
| # How can I make sure that the merchant attribute/association is set first so | |
| # that the foobar attribute checks my passed in merchant? | |
| c = FactoryGirl.create :customer, :merchant => @some_merchant, :foobar => 'xyz' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not disagreeing on that too, hence why I am using the patch till I hear other feedback from the authors.