[ACCEPTED]-Brakeman unsafe reflection method constantize called with model attribute-ruby
Accepted answer
You can go the other way around, finding 2 the class whose name is of chart_type
:
chart_class = [User, Category, Note, Post].find { |x| x.name == chart_type.classify }
if chart_class.nil?
raise "Unable to find the chart presenter"
end
ChartPresenter.new(chart_class.find(chart_id))
This way Brakeman 1 should be happy, and you are more secure...
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.