method

route_for

Importance_1
Ruby on Rails latest stable (v6.1.7.7) - 0 notes - Class: ActionDispatch::Routing::UrlFor
route_for(name, *args) public

Allows calling direct or regular named route.

resources :buckets

direct :recordable do |recording|
  route_for(:bucket, recording.bucket)
end

direct :threadable do |threadable|
  route_for(:recordable, threadable.parent)
end

This maintains the context of the original caller on whether to return a path or full URL, e.g:

threadable_path(threadable)  # => "/buckets/1"
threadable_url(threadable)   # => "http://example.com/buckets/1"
Show source
Register or log in to add new notes.