How could I get the routes namespace in the view?

I am currently working on an extension for spree. In this extension,
we introduce more roles than the current user and admin role. For the
new role, like a product supplier, we will only let them manage the
products information the supplier provide. So I created a routes.rb in
the extension like the following:

map.namespace :supplier do |supplier|
supplier.resources :products, :member => {:clone => :get}, :has_many
=> [:product_properties, :images] do |product|
product.resources :variants
product.resources :option_types, :member => { :select
=> :get, :remove => :get}, :collection => {:available
=> :get, :selected => :get}
product.resources :taxons, :member => {:select => :post, :remove
=> :post}, :collection => {:available => :post, :selected => :get}
end
supplier.resources :orders
supplier.resources :reports
end

And I wanted to reuse most of the code in the views and controllers.
But for the product management page, the code hardcode the url with
the admin name space as the following:

edit.html.erb for admin/products

<%= render :partial => ‘admin/shared/product_tabs’, :locals =>
{:current => “Product Details”} %>

admin/shared/product_tabs.html.erb

<li<%= ’ class=“active”’ if current == “Product Details” %>>
<%= link_to t(“product_details”), edit_admin_product_url(@product)
%>

I am wondering is there any way I could find the current namespace,
which is supplier to generate the url in a common partial or page?

Like when the admin use the edit.html.erb to render the page, the
partial url would be ‘admin/shared/product_tabs’, and
edit_admin_product_url(@product)

And when the supplier use the edit.html.erb to render the page, the
partial url would be
‘supplier/shared/product_tabs’, and
edit_supplier_product_url(@product)

Thanks.

Xu Wenhao wrote:

I am wondering is there any way I could find the current namespace,
which is supplier to generate the url in a common partial or page?

I haven’t taken the time to fully think this through, but on the surface
I would be questioning the need for views to have any direct knowledge
of routing. Routing is the responsibility of the controller layer.

In a properly partitioned MVC based web application, controllers should
be responsible for handling requests routed to them by lower level
framework code (the configured routes in routes.rb in the case of Rails)
and then render all the views to satisfy the needs of the request. The
views themselves should have no knowledge of controller
responsibilities.