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

Model with the column "type" breaks factory #43

Closed
eddanger opened this Issue Mar 24, 2010 · 4 comments

Comments

Projects
None yet
2 participants
@eddanger

eddanger commented Mar 24, 2010

Factory.define :proposal do |p|

p.type "Session"

end

Boom! `type': wrong number of arguments (1 for 0) (ArgumentError)

@eddanger

This comment has been minimized.

Show comment
Hide comment
@eddanger

eddanger Mar 24, 2010

I got around this (temporarily, hopefully) by doing the following:

p.after_build { |proposal| proposal.type = 'Session' }

eddanger commented Mar 24, 2010

I got around this (temporarily, hopefully) by doing the following:

p.after_build { |proposal| proposal.type = 'Session' }

@jpzwarte

This comment has been minimized.

Show comment
Hide comment
@jpzwarte

jpzwarte Mar 24, 2010

Use this instead:

f.add_attribute :type, type

jpzwarte commented Mar 24, 2010

Use this instead:

f.add_attribute :type, type
@eddanger

This comment has been minimized.

Show comment
Hide comment
@eddanger

eddanger Mar 24, 2010

That seemed to do the trick. What is the method "type" used for anyway?

eddanger commented Mar 24, 2010

That seemed to do the trick. What is the method "type" used for anyway?

@jpzwarte

This comment has been minimized.

Show comment
Hide comment
@jpzwarte

jpzwarte Mar 25, 2010

type is a reserved column in Rails used for single-table-inheritance. Type is also a method on Object that returns the class: http://ruby-doc.org/core/classes/Object.html#M000349

So you have to set the type attribute indirectly via add_attribute.

jpzwarte commented Mar 25, 2010

type is a reserved column in Rails used for single-table-inheritance. Type is also a method on Object that returns the class: http://ruby-doc.org/core/classes/Object.html#M000349

So you have to set the type attribute indirectly via add_attribute.

oggy pushed a commit to oggy/factory_girl that referenced this issue Feb 3, 2014

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment