|
|
|
|
|
by ryanstout
4293 days ago
|
|
So the models in volt basically let you read and assign attributes with an _ We could use the model[:key] instead, but the nice thing with using _ is that you can then define your own getters and setters easily in the model class. The _ is sort of a quick prototyping tool, allowing you to start using attributes without defining them in the model. We're going to add it where you can say something like: model_attr :field_name, String then do: model.field_name = 'something' (without the _) The _ keeps people from calling a method that isn't defined, since ._something will return nil if its not defined yet. But if you called .something, it will still raise an exception. Does all of that make since? |
|