Module: Enjoy::Goto::Controllers::Transfers

Extended by:
ActiveSupport::Concern
Included in:
TransfersController
Defined in:
lib/enjoy/goto/controllers/transfers.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/enjoy/goto/controllers/transfers.rb', line 6

def index
  url = Addressable::URI.heuristic_parse(params[:url]) rescue nil
  referer = (request.referer ? Addressable::URI.parse(request.referer) : nil) rescue nil

  @transfer = transfer_class.new
  @transfer.recieved_url = params[:url]
  @transfer.url = url.to_s
  @transfer.host = url.host.to_s if url
  @transfer.referer = referer.to_s
  @transfer.source_ip = request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip
  @transfer.save

  redirect_to @transfer.url, code: 303
end

#transfer_classObject



21
22
23
# File 'lib/enjoy/goto/controllers/transfers.rb', line 21

def transfer_class
  Enjoy::Goto::Transfer
end