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

Here, can i change the controller book and the action ruby for

loading
later ?

For example , we change the controller book to video, or change the

action ruby to php

If the controller be changed to video as i say above, so, the

controller
video will be loaded instead of the

the book.

end

loading later…

A custom controller and sereral actions.

class BookController < ActionController::Base
def ruby
#do something.
end

 def php
    #do something.
 end

 def python
    #do something.
 end

end

Thanks in advance.

On 9 September 2011 08:29, coolesting [email protected] wrote:

Here, can i change the controller book and the action ruby for loading

later ?

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

Colin

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

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.

On 9 September 2011 09:40, coolesting [email protected] wrote:

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.