Sha256: fb7451bc8e3cb80c98169f61ebf40ba8462a0922faae80806f6f6641078b043d

Contents?: true

Size: 623 Bytes

Versions: 7

Compression:

Stored size: 623 Bytes

Contents

module Effective
  class PermalinksController < ApplicationController
    include Effective::CrudController

    def show
      @permalink = Effective::Permalink.find_by! slug: params[:slug]

      authorize! :show, @permalink

      redirect_to redirect_path_for(@permalink), allow_other_host: (@permalink.target == :url)
    end

    private

    def redirect_path_for(permalink)
      permalink.target == :attachment ? attachment_url(permalink.attachment) : permalink.url
    end

    def attachment_url(permalink)
      Rails.application.routes.url_helpers.rails_blob_path(permalink, only_path: true)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
effective_pages-3.13.4 app/controllers/effective/permalinks_controller.rb
effective_pages-3.13.3 app/controllers/effective/permalinks_controller.rb
effective_pages-3.13.2 app/controllers/effective/permalinks_controller.rb
effective_pages-3.13.1 app/controllers/effective/permalinks_controller.rb
effective_pages-3.13.0 app/controllers/effective/permalinks_controller.rb
effective_pages-3.12.0 app/controllers/effective/permalinks_controller.rb
effective_pages-3.11.0 app/controllers/effective/permalinks_controller.rb