Sha256: 36e081b1cb07c85d89cd6dc536c1d6ccdfca66f6a2a05e46ff1698dc3b5243a0

Contents?: true

Size: 992 Bytes

Versions: 7

Compression:

Stored size: 992 Bytes

Contents

module Fume
  module RailsExt
    def self.try_enable
      if defined? ::ActionController
        ActionController::Base.send :include, ControllerExtensions
      end
    end
    
    module ControllerExtensions
      extend ActiveSupport::Concern
      
      included do
        helper_method :public_path, :public_url
      end
      
      module InstanceMethods
        
        protected
        def redirect_to_ok_url_or_default(default)
          redirect_to params[:ok_url] || default
        end
        
        def public_url(source)
          if source.include?("://")
            source
          else
            request.protocol + request.host_with_port + url_for("#{controller.config.relative_url_root}#{source}")
          end
        end

        def public_path(source)
          if source.include?("://")
            source
          else
            url_for("#{controller.config.relative_url_root}#{source}")
          end
        end
      end
    end
    
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fume-0.6.7 lib/fume/rails_ext.rb
fume-0.6.6 lib/fume/rails_ext.rb
fume-0.6.4 lib/fume/rails_ext.rb
fume-0.6.3 lib/fume/rails_ext.rb
fume-0.6.2 lib/fume/rails_ext.rb
fume-0.6.1 lib/fume/rails_ext.rb
fume-0.6.0 lib/fume/rails_ext.rb