Topic: Remove optional scope from path

Hello,

I need to modify this function:
  def self.remove_spree_mount_point(path)
    regex = Regexp.new '\A' + Rails.application.routes.url_helpers.spree_path
    path.sub( regex, '').split('?')[0]
  end

To not only remove the spree mount point but also the optional scope: 

  scope "(:locale)", :locale => /(en|es|ca)/ do
    mount Spree::Core::Engine, :at => '/'
  end

There is where I have Spree mounted. Probably I just need a method that tells me the optional scopes given a route and then proceed to remove them using RegExp.

Thanks

Last edited by nouboh (2013-07-18 12:35:09)