| Module | InheritedResources::ClassMethods |
| In: |
lib/inherited_resources/class_methods.rb
|
Defines wich actions will be inherited from the inherited controller. Syntax is borrowed from resource_controller.
actions :index, :show, :edit actions :all, :except => :index
Defines that this controller belongs to another resource.
belongs_to :projects
belongs_to :project, :parent_class => AdminProject
give a string. Added for ActiveRecord belongs to compatibility.
belongs_to :project, :instance_name => :my_project
belongs_to :project, :finder => :find_by_title!
This will make your projects be instantiated as:
Project.find_by_title!(params[:project_id])
Instead of:
Project.find(params[:project_id])
Default is :association_id, which in this case is :project_id.
helper. By default is association name.
suppose you have Tasks which belongs to Projects
which belongs to companies. This will do somewhere
down the road:
@company.projects
But if you want to retrieve instead:
@company.admin_projects
You supply the collection name.
type of polymorphic association)
Defines custom restful actions by resource or collection basis.
custom_actions :resource => [:delete, :transit], :collection => :search
custom_actions :resource => :delete
This macro creates 'delete' method in controller and defines
delete_resource_{path,url} helpers. The body of generated 'delete'
method is same as 'show' method. So you can override it if need
custom_actions :collection => :search
This macro creates 'search' method in controller and defines
search_resources_{path,url} helpers. The body of generated 'search'
method is same as 'index' method. So you can override it if need
Used to overwrite the default assumptions InheritedResources do. Whenever this method is called, it should be on the top of your controller, since almost other methods depends on the values given to <>defaults.
by the controller name. Defaults to Project in
ProjectsController.
is set on the index action. Defaults to :projects in
ProjectsController.
is set on all actions besides index action. Defaults to
:project in ProjectsController.
controllers. Default to :admin on Admin::ProjectsController.
defaults :finder => :find_by_slug