Instanciating a class

Hi i had a quick question.
if i have a class inside a folder say controllers >> plugins >>
test_plugin_conroller.rb, how can i get a reference to this class and
call .new on it to create an instance of it. Iv tried doing this:

@s = Kernel.const_get(“TestPluginController”)
@sc =

but it sais uninitialized constant TestPluginController, does anyone
have a solution? thank you for the help.


Why would you have a model inside of the controllers folder?

I believe you just need a require statement to load the model file if
it’s outside the normal models location.


test_plugin_controller.rb does contain

Class TestPluginController

, doesn’t it?

Also: check from the console that that class has actually been loaded
by your Rails app. If not, that’s probably the issue.

Otherwise, Kernel.const_get(“TestPluginController”).new should work.

Ok so i moved the plugin to models >> plugins >> test.rb

test.rb contains

class Test < ActiveRecord::Base

so i did
@s = Kernel.const_get(“Test”)
@sc =

and it said

Test is not a class

any other ideas? thank you so much for your help