Class: Shortenizer::UController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Shortenizer::UController
- Defined in:
- app/controllers/shortenizer/u_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/shortenizer/u_controller.rb', line 13 def create @url = Shortenizer::Url.new(url_params) if @url.save flash[:message] = "Your URL has been shortened..." else flash[:message] = "Error occured, please try again!" end redirect_to action: :show, shortlink: @url.shortlink end |
#index ⇒ Object
4 5 6 7 |
# File 'app/controllers/shortenizer/u_controller.rb', line 4 def index target = Url.find_by(shortlink: params[:shortlink]).target redirect_to target end |
#new ⇒ Object
9 10 11 |
# File 'app/controllers/shortenizer/u_controller.rb', line 9 def new @url = Shortenizer::Url.new end |
#show ⇒ Object
25 26 27 28 |
# File 'app/controllers/shortenizer/u_controller.rb', line 25 def show url_obj = Url.find_by(shortlink: params[:shortlink]) @url = Shortenizer::UrlPresenter.new(url_obj, request) end |