Rails wildcard routes : vs *

I'm starting to learn rails, and I'm seeing the terminology wildcard routes, but I've seen routes listed both of the following ways:

/a/path/*all', :all => /.*/

and

/a/path/:all

What is the difference between these two route forms?

Answers


Have you read the Rails Guide on routing yet? That is a great place to start learning about routing in Rails.

For instance, you will learn that your 2nd code block is not a wildcard route. Instead it matches what the guide above refers to as a Static Segment

You'll also learn that to impose restrictions on a segment as you appear to be attempting in the first code block, you must use the :constraints option, such as this wildcard route, or as the guide above refers to them, Route Globbing

GET  "/a/path/*all", :constraints => { :all => /.*/ }

However, the above constraint is redundant since the wildcard *all is going to match .* by default anyway.


Need Your Help

How to mangle JavaScript strings using hexadecimal escape?

javascript node.js obfuscation

I need to mangle (obfuscate) JavaScript strings using hexadecimal encoding.

Session management using Hibernate in a Swing application

java database hibernate swing session

How do you do your Hibernate session management in a Java Desktop Swing application? Do you use a single session? Multiple sessions?