instance method
member
Ruby on Rails 6.1.7.10
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 1543
def member
unless resource_scope?
raise ArgumentError, "can't use member outside resource(s) scope"
end
with_scope_level(:member) do
if shallow?
shallow_scope {
path_scope(parent_resource.member_scope) { yield }
}
else
path_scope(parent_resource.member_scope) { yield }
end
end
end
Defined in actionpack/lib/action_dispatch/routing/mapper.rb line 1543
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Routing::Mapper::Resources