Changing the controller and action before that will be loaded.

Hi, guys.

My problem is when i touch the route like ‘/book/ruby’ that will loads the ApplicationController first,
and then loads the action ruby of the controller book, the loading order as the following,

First loading

class ApplicationController < ActionController::Base
protect_from_forgery

Why not just change the route to invoke the action that you want?

Colin

Because this situation is automatic, i don't know it needs to change
the controller book to which the anther controller or action.
So, i can't bundle it into route in that file, in other words, the
controller or action name will be stored to database.

Because this controller or action name is automatic, it will be stored
into database instead of that route file.

(please leave some context from the message you're replying to to save
us the hassle of trawling through our deleted items :-/

If your user requests '/books/ruby' with standard routing it would
pass the :id of 'ruby' to the index action of the books controller (if
you want your controller to be '/book/' you'll need to map a custom
route to that).

So in the index action, if you perform some custom operation (like a
case switch on params[:id] or a find_by_other_field) to determine
which other method to call, you should be able to take it from there.