

Rails now supports routes prefixed with word cable
source link: https://blog.saeloun.com/2022/12/08/rails-support-routes-prefixed-with-word-cable
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Rails now supports routes prefixed with word cable
Dec 8, 2022 , by Prasanth Chaduvula
1 minute read
ActionCable seamlessly integrates WebSockets with the rest of our Rails application. It allows for real-time features to be written in Ruby in the same style and form the rest of our Rails application, while still being performant and scalable. It’s a full-stack offering that provides both a client-side JavaScript framework and a server-side Ruby framework. We have access to our entire domain model written with ActiveRecord or ORM of our choice.
Rails have resourceful routing. Resource routing allows us to quickly declare all of the common routes for a given resourceful controller. A single call to resources can declare all of the necessary routes for our index, show, new, edit, create, update, and destroy actions.
Earlier, whenever we navigate to a route prefixed with the word cable
like /cable-slug
resulted in a 404 error.
Now it got fixed with the recent release.
Before
Navigating to a route that is prefixed with #{Rails.application.config.action_cable.mount_path}- 404s But navigating to a route that is prefixed with #{Rails.application.config.action_cable.mount_path}_ works.
http://localhost:3000/cable-hypenated-slug -> 404
http://localhost:3000/cable_underscored_slug -> 200
The same is true regardless of the mount path:
# config.action_cable.mount_path = "/dev/cable"
http://localhost:3000/dev/cable-hyphenated-slug -> 404
http://localhost:3000/dev/cable_underscored_slug -> 200
After
Thanks to this PR: with this latest Rails version v7.0.4 it is possible to navigate to routes prefixed with word cable.
The ActionCable server is now mounted with anchor: true
.
This means that routes that also start with /cable
will no longer clash with Action Cable.
http://localhost:3000/cable-hypenated-slug -> 200
http://localhost:3000/cable_underscored_slug -> 200
http://localhost:3000/dev/cable-hyphenated-slug -> 200
http://localhost:3000/dev/cable_underscored_slug -> 200
Recommend
-
33
How to separate & group your routes by logical entities
-
17
rails routes中resource和resources的区别 欢迎转载,请支持原创,保留原文
-
5
Dispatching legacy webkit prefixed events (but only some of the time)Dispatching legacy webkit prefixed events (but only some of the time) 22 Feb 2016 Here’s a twist on the classic “browser has bug, developers change to w...
-
13
prefixed requestAnimationFrame greatest hitsprefixed requestAnimationFrame greatest hits 13 Aug 2014 Vendor prefixes are a funny thing. Mix them with global WebIDL own properties and it gets weird. From
-
8
Something about backformation or analogy to vendor prefixed APIs.Something about backformation or analogy to vendor prefixed APIs. 19 Nov 2013 There’s a few APIs that exist on the web created by
-
12
Harun Sabljaković for Wizard Healt...
-
1
Intelligent Backend Routes with Rails and nginxJuly 17, 2016Introduction A fairly common deployment involves running nginx as the first hop on an application server, which in turn routes to your backend. This blog is bas...
-
13
Capitalization of Vendor-Prefixed CSS Property Names in JavaScript I just spent a little too long chasing down the answer to this question: When using an element’s JavaScript styles interface, the
-
4
Prefixed API Key (Seam-style) Example key: mycompany_BRTRKFsL_51FwqftsmMDHHbJAMEXXHCgG Seam-style API Keys have many advantages: Double clicking the api key selects the entire ap...
-
7
Rails extends routes searching to include dynamic URL params Sep 6, 2022 , by Swaathi Kakarla 1 minute read ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK