Hello, 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:> 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> > > -philipThanks, I was searching for that :D -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
But how does this reflect the views ? I want also be able to put the different layouts like this /views/blog/post/create.rhtml /views/blog/comment/create.rhtml :D -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---