Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "mount" instruction mean in Rails routing?

I cannot find the meaning of the keyword "mount" in Rails routing system.


I have set up Mercury to use within my Rails application. It added this line to my routes.rb config file:

Appname::Application.routes.draw do
  mount Mercury::Engine => '/'

What does the mount keyword mean?

like image 426
Gabriel S. Avatar asked Mar 03 '14 10:03

Gabriel S.


People also ask

How do I see all routes in Rails?

TIP: If you ever want to list all the routes of your application you can use rails routes on your terminal and if you want to list routes of a specific resource, you can use rails routes | grep hotel . This will list all the routes of Hotel.

What does rake routes do?

rake routes will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you're trying to get familiar with.

What is routing in Ruby on Rails?

The routing module provides URL rewriting in native Ruby. It's a way to redirect incoming requests to controllers and actions. It replaces the mod_rewrite rules. Best of all, Rails' Routing works with any web server. Routes are defined in app/config/routes.


2 Answers

Mount within the Rails routes does the equivalent of a Unix mount.
It actually tells the app that another application (usually a Rack application) exists on that location.

It is used mostly for Rails Engines.

like image 169
xlembouras Avatar answered Oct 15 '22 07:10

xlembouras


Mounting an engine means that the functionality from that engine is available inside your application.

See http://guides.rubyonrails.org/engines.html#mounting-the-engine

like image 33
sevenseacat Avatar answered Oct 15 '22 09:10

sevenseacat