This is expected because this is how ActiveRecord works on the project. If you need to set arbitrary attributes, you will have to use objects of a different type.
For example, Ruby provides a library called OpenStruct that allows you to create objects in which you can assign arbitrary keys / values. You might want to use such a library and then convert the object to the corresponding ActiveRecord instance only if / when you need to save it to the database.
Do not try to model ActiveRecord so that it behaves the way you just described, because it just was not designed to behave that way. This would be a cargo theft mistake from your current knowledge of PHP.
source share