Class: Decidim::ShortLinksController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Decidim::ShortLinksController
- Defined in:
- app/controllers/decidim/short_links_controller.rb
Overview
Redirects users with short links to the correct location on the site.
Instance Method Summary collapse
-
#index ⇒ Object
The index action redirects the user to the application root in case someone tries to request the short link URL without an identifier.
-
#show ⇒ Object
Redirects the user to the target URL that the short link is set to redirect to.
Instance Method Details
#index ⇒ Object
The index action redirects the user to the application root in case someone tries to request the short link URL without an identifier.
10 11 12 |
# File 'app/controllers/decidim/short_links_controller.rb', line 10 def index redirect_to decidim.root_path, status: :moved_permanently end |
#show ⇒ Object
Redirects the user to the target URL that the short link is set to redirect to. Raises an ActionController::RoutingError in case a short link does not exist with the given identifier.
20 21 22 23 24 |
# File 'app/controllers/decidim/short_links_controller.rb', line 20 def show raise ActionController::RoutingError, "Not Found" unless link redirect_to link.target_url, status: :moved_permanently end |