Ezra Zygmuntowicz
2/22/2007 9:35:00 PM
Hi~
On Feb 22, 2007, at 1:21 PM, Wes Gamble wrote:
> All,
>
> In my Rails app., I'm doing something like this:
>
> eval("#{requested_controller_class}.respond_to?
> ('session_data_not_needed_by?')")
>
> where requested_controller_class is the name of an existing
> (controller)
> class.
>
> Is the above code the best of way of invoking respond_to? on the class
> in question, or is there some better way to get the actual class
> object
> based solely on it's name?
>
> Thanks,
> Wes
Since you are in a Rails app the better way of doing that would be
like this:
requested_controller_class.constantize.respond_to? :session_data_not_nee
ded_by?
Cheers-
-- Ezra Zygmuntowicz
-- Lead Rails Evangelist
-- ez@engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)