Class: ShortUrlsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/short_urls_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


6
7
8
9
10
11
12
13
14
# File 'app/controllers/short_urls_controller.rb', line 6

def create
  @short_url = ShortUrl.new(permitted_params)

  if @short_url.save
    render :show
  else
    render :new
  end
end

#followObject


16
17
18
19
20
# File 'app/controllers/short_urls_controller.rb', line 16

def follow
  short_url = ShortUrl.find_by(key: params[:key])

  redirect_to short_url.url
end

#newObject


2
3
4
# File 'app/controllers/short_urls_controller.rb', line 2

def new
  @short_url = ShortUrl.new
end