Class: Decidim::ShortLinksController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- 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.
Methods included from UserBlockedChecker
#check_user_block_status, #check_user_not_blocked
Methods included from NeedsSnippets
Methods included from Headers::HttpCachingDisabler
Methods included from HasStoredPath
#skip_store_location?, #store_current_location
Methods included from TranslatableAttributes
Methods included from RegistersPermissions
Methods included from NeedsOrganization
enhance_controller, extended, included
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 |