Sha256: 69c20cd67b65ebb2a9de41a36184946952fab21198ee0e0cca9f00f6a992663c

Contents?: true

Size: 585 Bytes

Versions: 17

Compression:

Stored size: 585 Bytes

Contents

# frozen_string_literal: true

module Tanshuku
  # A Rails controller class for finding a {Tanshuku::Url} record and redirecting to its shortened URL.
  class UrlsController < ActionController::API
    # Finds a {Tanshuku::Url} record from the given +key+ parameter and redirects to its shortened URL.
    #
    # @return [void]
    #
    # @raise [ActiveRecord::NotFound] If no {Tanshuku::Url} record is found for the given +key+.
    def show
      url = Url.find_by!(key: params[:key])
      redirect_to url.url, status: :moved_permanently, allow_other_host: true
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
tanshuku-4.0.0 app/controllers/tanshuku/urls_controller.rb
tanshuku-2.0.1 app/controllers/tanshuku/urls_controller.rb
tanshuku-1.0.1 app/controllers/tanshuku/urls_controller.rb
tanshuku-3.0.3 app/controllers/tanshuku/urls_controller.rb
tanshuku-3.0.2 app/controllers/tanshuku/urls_controller.rb
tanshuku-3.0.1 app/controllers/tanshuku/urls_controller.rb
tanshuku-3.0.0 app/controllers/tanshuku/urls_controller.rb
tanshuku-2.0.0 app/controllers/tanshuku/urls_controller.rb
tanshuku-1.0.0 app/controllers/tanshuku/urls_controller.rb
tanshuku-0.0.20 app/controllers/tanshuku/urls_controller.rb
tanshuku-0.0.19 app/controllers/tanshuku/urls_controller.rb
tanshuku-0.0.18 app/controllers/tanshuku/urls_controller.rb
tanshuku-0.0.17 app/controllers/tanshuku/urls_controller.rb
tanshuku-0.0.16 app/controllers/tanshuku/urls_controller.rb
tanshuku-0.0.15 app/controllers/tanshuku/urls_controller.rb
tanshuku-0.0.14 app/controllers/tanshuku/urls_controller.rb
tanshuku-0.0.13 app/controllers/tanshuku/urls_controller.rb