method
resources
v3.0.0 -
Show latest stable
- Class:
ActionDispatch::Routing::Mapper::Resources
resources(*resources, &block)public
No documentation available.
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 581
def resources(*resources, &block)
options = resources.extract_options!
if apply_common_behavior_for(:resources, resources, options, &block)
return self
end
resource_scope(Resource.new(resources.pop, options)) do
yield if block_given?
collection_scope do
get :index if parent_resource.actions.include?(:index)
post :create if parent_resource.actions.include?(:create)
end
new_scope do
get :new
end if parent_resource.actions.include?(:new)
member_scope do
get :edit if parent_resource.actions.include?(:edit)
get :show if parent_resource.actions.include?(:show)
put :update if parent_resource.actions.include?(:update)
delete :destroy if parent_resource.actions.include?(:destroy)
end
end
self
end 1Note
The :path option
The path option will actually set the path and not the prefix I have found in Rails 3.0.5.
==== Example
resources :my_reports, :path => 'my-reports'
All actions for this resource will now be at /my-reports.