Class: Tanshuku::UrlsController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/tanshuku/urls_controller.rb

Overview

A Rails controller class for finding a Url record and redirecting to its shortened URL.

Instance Method Summary collapse

Instance Method Details

#showvoid

This method returns an undefined value.

Finds a Tanshuku::Url record from the given key parameter and redirects to its shortened URL.

Raises:

  • (ActiveRecord::NotFound)

    If no Tanshuku::Url record is found for the given key.



11
12
13
14
# File 'app/controllers/tanshuku/urls_controller.rb', line 11

def show
  url = Url.find_by!(key: params[:key])
  redirect_to url.url, status: :moved_permanently, allow_other_host: true
end