RubyMoney / money-rails

Integration of RubyMoney - Money with Rails
MIT License
1.8k stars 387 forks source link

ArgumentError if the monetized attribute name contains hyphens #699

Open afdev82 opened 5 months ago

afdev82 commented 5 months ago

Hi all,

while trying to add a monetized attribute called 'custom_frame-price', I was getting the following error:

ArgumentError (Model already has a monetized attribute called 'custom_frame-price')

The error was misleading, I didn't understand why for a couple of hours, the reason was another error that was thrown before and it was not visible in the browser (only the last one was visible):

NameError (invalid attribute name `custom_frame-price_money_before_type_cast'):

I have tried then to rename the attribute without the hyphen and it worked. Should we add a warning in the README about that? Something like "WARNING: Do not use hyphens in the name of the attribute"? I am using them in my application, in Ruby/Rails is a valid name.