I am writing a Ruby on Rails 4.1 app with Ruby 2.11. The structure is Domain -> Team -> User. So, a user belongs to a team and I sometimes need to make a team from a domain (so they are associated). Think Starbucks -> NY Central Team -> Mr Barista.
I have made some builder classes and put them in app/builders, but when I try to use the class it says uninitialized constant in the Rails console. So, for example, I have the file in app/builders/team_builder.rb
:
class TeamBuilder
attr_reader :domain, :params
def initialize(domain, params = {})
@domain = domain
@params = params
end
def build
domain.teams.build(params)
end
end
But when I type TeamBuilder.new(domain, name: 'Team name here!')
I get the response
NameError: uninitialized constant TeamBuilder
It seems like it does not recognise the new class I have added above, which makes me think it is not loading it. But I thought that all sub-directories in app/ were loaded.
Totally stumped on this one, and I cannot find a guide or documentation on this (maybe it's there - somewhere...)