Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails STI #39

Closed
releu opened this issue Oct 10, 2011 · 1 comment
Closed

Rails STI #39

releu opened this issue Oct 10, 2011 · 1 comment

Comments

@releu
Copy link

releu commented Oct 10, 2011

I have class Payment < ActiveRecord::Base and class Osmp < Payment.
When I osmp = Factory(:osmp) then I got error ActiveRecord::SubclassNotFound:

The single-table inheritance mechanism failed to locate the subclass: 'type'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Deal.inheritance_column to use another column for that information.

This is a bug or something I did not do so?

@jferris
Copy link
Member

jferris commented Oct 10, 2011

If you're using STI with factory_girl, you'll need to override the build_class or avoid child factories, since child factories share a build class with their parent by default.

FactoryGirl.define do
  factory :payment do
    # common fields
  end

  factory :osmp, :class => 'Osmp' do
    # osmp-specific fields
  end
end

@jferris jferris closed this as completed Oct 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants