instance method
member
Ruby on Rails 3.1.12
Since v3.0.20Signature
member()
To add a member route, add a member block into the resource block:
resources :photos do member do get 'preview' end end
This will recognize /photos/1/preview with GET, and route to the preview action of PhotosController. It will also create the preview_photo_url and preview_photo_path helpers.
Source
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 1189
def member
unless resource_scope?
raise ArgumentError, "can't use member outside resource(s) scope"
end
with_scope_level(:member) do
scope(parent_resource.member_scope) do
yield
end
end
end
Defined in actionpack/lib/action_dispatch/routing/mapper.rb line 1189
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Routing::Mapper::Resources