How Routing Rails?



I’m trying to do develop some modules so I can reuse all my codes in
different projects.

I need to put routing in different files, and in route.rb include the
files which have my routing code, but I don’t know if this would work?

Example, the following lines is inside route_account.rb.

map.login ‘login’, :controller => ‘accounts’, :action => ‘login’
map.login ‘signup’, :controller => ‘accounts’, :action => ‘signup’
map.logout ‘logout’, :controller => ‘accounts’, :action => ‘logout’
map.account ‘account’ :controller => ‘accounts’, :action => ‘account’

I tried to include the line below in route.rb, but that wouldn’t work?

include ‘route_account.rb’
or load ‘route_account.rb’ or require ‘route_account’

Any help would be appropriated :slight_smile: and thanks


Thanks for your help!


Yamal Khaled Soueidan wrote:

map.login ‘login’, :controller => ‘accounts’, :action => ‘login’


Thanks for your help!

Phillip “CynicalRyan” Gawlowski

Rule of Open-Source Programming #15:

If you like it, let the author know. If you hate it, let the author
know why.


When you just have the lines in route_account.rb, what do you think
that “map” refers to?

  1. How Kernel#load, Kernel#require work. They do not simply “insert
    text” from the supplied file. Rather, they will execute (effectively,
  2. What does “map” mean? It needs to be an instance of
    Action::Controller::Routes, either though a block or a constructor.

This is really the wrong list, though. You should try for questions like