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 = @st.new

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

Brandon

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.

Jason

test_plugin_controller.rb does contain

Class TestPluginController
stufff
end

, 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
end

so i did
require(“models/plugins/test.rb”)
@s = Kernel.const_get(“Test”)
@sc = @st.new

and it said

Test is not a class

any other ideas? thank you so much for your help