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

Allow passing extra arguments #49

Closed
pupeno opened this issue Apr 19, 2010 · 6 comments
Closed

Allow passing extra arguments #49

pupeno opened this issue Apr 19, 2010 · 6 comments
Labels

Comments

@pupeno
Copy link

pupeno commented Apr 19, 2010

Could you make it possible to allow to pass extra arguments to be used in the callbacks or in some other ways.

To be able to do something like this:

Factory.define :blog do |blog|
  blog.name "Blah"

  blog.after_create do |blog|
    blog.posts += sample_posts
    blog.save!
  end
end

and then create it with something like this:

Factory.create(:blog, :sample_posts => [post1, post2])

Thanks.

@jferris
Copy link
Contributor

jferris commented Jun 23, 2010

Thanks for the idea. However, I don't think I want to add arbitrary arguments for callbacks to factory_girl. Is there a reason you couldn't just use #posts in the above example?

@pupeno
Copy link
Author

pupeno commented Jun 23, 2010

I'm sorry, what do you mean by #posts?

@jferris
Copy link
Contributor

jferris commented Jun 23, 2010

Can you do this instead?

Factory.create(:blog, :posts => [post1, post2])

@pupeno
Copy link
Author

pupeno commented Jun 23, 2010

That should work, shouldn't it? I don't remember whether I tried or not. Sorry :(

@ahamid
Copy link

ahamid commented Feb 7, 2012

it would be convenient to be able to specify parameters, which are not themselves attributes on the model, to generate attributes, and not have these set on the generated object.

@ahamid
Copy link

ahamid commented Feb 9, 2012

nevermind, transient attributes does this perfectly! #141 #142 sorry for the bump

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants