module ActionDispatch::Routing::Mapper::Resources
def resource(*resources, &block)
### Options
form_with(model: @profile) {}
# Enables this to work with singular routes:
resolve('Profile') { [:profile] }
resource :profile
[resolve](rdoc-ref:CustomUrls#resolve):
identification (e.g. in `form_with` or `redirect_to`), you will need to call
If you want instances of a model to work with this resource via record
POST /profile
DELETE /profile
PATCH/PUT /profile
GET /profile/edit
GET /profile
GET /profile/new
`Profiles` controller (note that the controller is named after the plural):
This creates six different routes in your application, all mapping to the
resource :profile
(rather than /profile/:id) to the show action:
logged in user. In this case, you can use a singular resource to map /profile
an ID. A common example, /profile always shows the profile of the currently
Sometimes, you have a resource that clients always look up without referencing
def resource(*resources, &block) options = resources.extract_options!.dup if apply_common_behavior_for(:resource, resources, options, &block) return self end with_scope_level(:resource) do options = apply_action_options :resource, options resource_scope(SingletonResource.new(resources.pop, api_only?, @scope[:shallow], options)) do yield if block_given? concerns(options[:concerns]) if options[:concerns] new do get :new end if parent_resource.actions.include?(:new) set_member_mappings_for_resource collection do post :create end if parent_resource.actions.include?(:create) end end self end