Sha256: 7edd540a932fdd540c6043f46f1de4b34b3dc36e9c1c6fb1c45b922fdda03f34

Contents?: true

Size: 623 Bytes

Versions: 1

Compression:

Stored size: 623 Bytes

Contents

module RobotsDotText
  module Controller
    extend ActiveSupport::Concern

    def show
      begin
        render file: robots_file_path, layout: false, content_type: 'text/plain'
      rescue ActionView::MissingTemplate
        render file: default_robots_path, layout: false, content_type: 'text/plain'
      end
    end

    private

    def robots_file_path
      File.join([Rails.root, 'public', "robots.#{robots_file_descriptor}.txt"])
    end

    def default_robots_path
      File.join([Rails.root, 'public', 'robots.default.txt'])
    end

    def robots_file_descriptor
      Rails.env.to_s
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
robots_dot_text-0.0.3 lib/robots_dot_text/controller.rb