Are there any implications or gotchas to passing in a class instead of a string when defining an association?
belongs_to :owner, class_name: User
As opposed to:
belongs_to :owner, class_name: "User"
The class may not be loaded yet in which case you'll get a NameError: uninitialized constant User
.
You're supposed to use "User"
for this reason, as implied by the option name: :class_name
, not :class
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With