Sha256: 20299a9226f2caeb654df4c7ae96cc3f5a61276b181f801f24dc61c2d9c114e7

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

module MultiSite::PagesControllerExtensions
  def self.included(base)
    base.class_eval {
      alias_method :discover_current_site_without_root, :discover_current_site
      alias_method :discover_current_site, :discover_current_site_with_root

      alias_method :index_without_site, :index

      alias_method :continue_url_without_site, :continue_url
      alias_method :continue_url, :continue_url_with_site

      alias_method :remove_without_back, :remove
      alias_method :remove, :remove_with_back
      responses.destroy.default do
        return_url = session[:came_from]
        session[:came_from] = nil
        if model.class == Page or model.class < Page
          redirect_to return_url || admin_pages_url(:site_id => model.site.id)
        else
          redirect_to continue_url(params)
        end
      end
    }
  end

  # for compatibility with the standard issue of multi_site,
  # a root parameter overrides other ways of setting site

  def discover_current_site_with_root
    site_from_root || discover_current_site_without_root
  end

  def site_from_root
    if params[:root] && @homepage = Page.find(params[:root])
      @site = @homepage.root.site
    end
  end

  def remove_with_back
    session[:came_from] = request.env["HTTP_REFERER"]
    remove_without_back
  end

  def continue_url_with_site(options={})
    options[:redirect_to] || (params[:continue] ? edit_admin_page_url(model) : admin_pages_url(:site_id => model.site.id))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/extensions/multi-site-extension/lib/multi_site/pages_controller_extensions.rb
trusty-cms-7.0.11 vendor/extensions/multi-site-extension/lib/multi_site/pages_controller_extensions.rb
trusty-cms-7.0.10 vendor/extensions/multi-site-extension/lib/multi_site/pages_controller_extensions.rb
trusty-cms-7.0.9 vendor/extensions/multi-site-extension/lib/multi_site/pages_controller_extensions.rb