I have a model class called Person. The person class has a attribute called car.
Now I would like to define a module in the concerns model called Person::Car::HasProducer
The module should look like that:
module HasProducer
def produced_by_toyota?
car == "Prius"
end
def produced_by_bmw?
car == "X3" || car == "X5"
end
end
I would like to locate this file under: concerns/person/car/has_producer.rb
In the Person-class I tried to include it like that:
class Person
include Person::Car::HasProducer
But there I get the error: Unable to autoload constant Person::Car::HasProducer
I tried different combinations of modules/classes but none of the constellation worked for me.
What do I have to do so that has_producer.rb get's found as Person::Car::HasProducer?
Aucun commentaire:
Enregistrer un commentaire