inherit controller, how to do it?

I'm doing small blog for myself, I faced a problem when I want some
controller to inherit.

class BlogController < ApplicationController

end

class PostController < BlogController
def list
   render :text => "asd"
end
end

class CommentController < PostController
def list
   render :text => "asd"
end
end

So when I visit

http://domain.com/blog/post/list

I get "asd", shouldn't it be like that?

Nope. When you inherit a controller like you've done, all you are doing is giving your Comment/Post controllers access to the methods in BlogController.

So you could move your list() action up into BlogController, take it out of the other two and then call: domain.com/post/list and domain/comment/list and you'd be *running* the BlogController.list action.

To get that heiararchy you want something like this:

app/controllers/admin/admin_controller.rb
app/controllers/admin/photo_controller.rb

that start off with these:

class Admin::AdminController < ApplicationController
class Admin::PhotoController < Admin::AdminController

Then you can call domain.com/admin/photo/<action goes here>

-philip