lib/moxify.rb in moxify-0.1.7.1 vs lib/moxify.rb in moxify-0.1.7.2

- old
+ new

@@ -1,10 +1,12 @@ require 'refinerycms-base' require 'moxify/version' module Moxify + autoload :URLTempfile, 'moxify/url_tempfile' + class Engine < Rails::Engine initializer "static assets" do |app| app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public" end @@ -26,14 +28,26 @@ initializer "moxify.override_routing", :after => :disable_dependency_loading do |app| # override routes collected_routes = [] Rails.application.routes.routes.each do |route| + match = false + if route.path =~ /refinery/ and not route.path =~ /^\/refinery\(\/\*path\)/ # this is our catch all route route.instance_variable_set "@path", route.path.gsub(/refinery/, "admin") + match = true + elsif route.path =~ /^\/users/ and + route.name =~ /user\_/ + + route.instance_variable_set "@path", route.path.gsub(/users/, "admin") + match = true + + end + + if match # make sure we generate new path_info for changed paths conditions = route.conditions conditions[:path_info] = ::Rack::Mount::Strexp.compile(route.path, route.requirements, ::ActionDispatch::Routing::SEPARATORS, true) # overwrite conditions with new path_info