Models class from Controller name

suggest change

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Naming conventions:
*Models class from Controller name

Table Of Contents
6Naming conventions
55CSV