Read more

FactoryBot: How to get the class from a factory name

Arne Hartherz
March 12, 2015Software engineer at makandra GmbH

When you want to look up a class for a given factory, do it like this:

>> FactoryBot.factories.find('admin').build_class
=> User
Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot

In older versions, you could do:

>> FactoryBot.factory_by_name('admin').build_class
=> User
Posted by Arne Hartherz to makandra dev (2015-03-12 10:38)