Ruby on Rails - Models class from Controller name in ruby on rail - ruby on rails tutorial - rails guides - rails tutorial - ruby rails
Models class from Controller name-in-ruby-on-rails
You can get a Model class from a Controller name this way (context is Controller class):
class MyModelController < ActionController::Base
# Returns corresponding model class for this controller
# @return [ActiveRecord::Base]
def corresponding_model_class
# ... add some validation
controller_name.classify.constantize
end
end