Optional Dynamic Prepended Route via scope

Hello,

Say I have the following in my routes file:

scope “(/:organization)” do
resources :systems, :except => [:destroy] do
member do
get :packages
end
end
end

resources :dashboard do
collection do
get :notices
end

The organization can be changed by the user and various resources such
as systems are scoped off of the organization. So, the organization
can change dynamically and so as to be restful we want to prepend the
organization to each route within that scope. Following the Rails
guides, I attempted to use:

default_url_options()
{ :organization => current_organization.name }
end

Which generated URLs in the way desired, e.g. /Organization1/system/
However, the URLs generated (via _path() calls, e.g. dashboard_path())
include the extra paramter ?organization=Organization1 which is not
the behavior desired for this application.

My question then is - is it possible to have the organization set and
included for only those routes that declare a scope of /:organization.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs