views:

58

answers:

2

I can do this in the controller to get the model class:

self.class.name.gsub("Controller", "").singularize.constantize

But is there a built in method for this in the controller?

Something like self.model_class?

Thanks!

+2  A: 

action:pack and active:record are separated so this isn't possible.

Sam
+1  A: 
params[:controller].classify.constantize
jordinl
Shouldn't this be `params[:controller].classify.constantize`?
zetetic
yeah, fixed it. thanks!
jordinl
I don't think this does what viatropos is asking. He wants the name of the *model* from inside a controller, and this gives the controller. Controllers do not have inherent connections to models, so I believe Sam's answer is the correct one.
Jimmy Cuadra
I assumed that he wanted User inside UsersController. Otherwise, as you and Sam say, it's impossible
jordinl