Another Reason to Avoid constantize in Rails

17-Sep-2020 2592
Backstory Recently, a friend asked me if just calling constantize on user input was dangerous, even if subsequent code did not use the result: 1 … The constantize method in Rails turns a string into a constant. If the constant does not exist then a NameError will be raised.However, it is possible to hook into the constant lookup process in Ruby by defining a const_missing method. If a constant cannot be found in a given module, and that module has const_missing defined, then const_missing will be invoked.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle