Forum: Ruby on Rails calling the controller in string

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
043efdc2a79afbfec84696f50fd42163?d=identicon&s=25 onurturgay (Guest)
on 2005-11-17 09:44
(Received via mailing list)
Hi,
I have string or symbol that holds a controllers name (like 'user' or
:user). How can I call one of the class methods of this controller?
Thanks in advance
Fdc7ff1d176325ed86c81c7c4584f0ad?d=identicon&s=25 dmitry (Guest)
on 2005-11-17 21:35
(Received via mailing list)
On Thursday 17 November 2005 15:42, Onur Turgay wrote:
> Hi,
> I have string or symbol that holds a controllers name (like 'user'
> or :user). How can I call one of the class methods of this
> controller?
Try:
str = "user" # or :user
kontroller = "#{str}_controller".camelize.constantize
kontroller.any_method_you_want
This topic is locked and can not be replied to.