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