The app returns the number of records based on a variable name in my route. So if I have a “Person” model and a “Car” model (or any number of other ones), I want to be able to assign any of these to a variable and get results from it.
I’ve tried:
@model = params[:model]
@model.find(:all).count
and I get the error:
undefined method `find' for "Person":String
Thanks for any help!
Try this:
Constantize turns a string in to a constant.