# File lib/refinerycms-theming.rb, line 16
          def attach_theme_to_refinery
            # remove any paths relating to any theme.
            view_paths.reject! { |v| v.to_s =~ %r{^themes/} }

            # add back theme paths if there is a theme present.
            if (theme = ::Theme.current_theme(request.env)).present?
              # Set up view path again for the current theme.
              view_paths.unshift ::Theme.current_theme_dir.join("views").to_s

              # Ensure that routes within the application are top priority.
              # Here we grab all the routes that are under the application's view folder
              # and promote them ahead of any other path.
              view_paths.select{|p| p.to_s =~ %r{^#{Rails.root.join('app', 'views')}}}.each do |app_path|
                view_paths.unshift app_path
              end
            end

            # Set up menu caching for this theme or lack thereof
            if RefinerySetting.table_exists? and
               RefinerySetting.get(:refinery_menu_cache_action_suffix) != (suffix = "#{"#{theme}_" if theme.present?}site_menu")
              RefinerySetting.set(:refinery_menu_cache_action_suffix, suffix)
            end
          end