Created
November 29, 2011 16:49
-
-
Save r00k/1405490 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 Cycle < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :decision, polymorphic: true | |
validates :user_id, presence: true | |
validates :decision_id, presence: true | |
validates :decision_type, presence: true | |
validates :effective_at, presence: true | |
end |
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
FactoryGirl.define do | |
#... | |
factory :rental do | |
product | |
end | |
factory :cycle do | |
user | |
decision rental | |
effective_at { Date.beginning_of_this_month } | |
end | |
end |
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 Rental < ActiveRecord::Base | |
has_one :cycle, as: :decision | |
belongs_to :product | |
end |
Author
r00k
commented
Nov 29, 2011
Removing line 11 in factories.rb stops the error.
Just in case someone else finds this someday: the issue was the association in the cycle factory needed to be declared like
factory :cycle do
user
association :decision, factory: rental # this is the change
effective_at { Date.beginning_of_month }
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment