milic
2008-Mar-28 17:29 UTC
Inheriting from AdminController intstead from ApplicationController
Hi I would like to do the following: I have created an admin namespace and the required folders app/admin views/admin etc. And then I wanted all controllers under app/admin to inherit from a controller named AdminController which resists under app/admin/admin.rb instead of inhereting from ApplicationController, so I could better separate between admin and public section. The AdminController looks like this: module Admin class AdminController < ActionController::Base include AuthenticatedSystem helper :all protect_from_forgery layout ''admin/layouts/admin'' end end For testing the new namespace I created a GroupsController which looks like this: require ''admin/admin'' module Admin class GroupsController < AdminController def index @groups = Group.find(:all) end end end But every time I call the GroupsController I''m getting the following error: uninitialized constant Admin::AdminController Can anybody tell me what I''m doing wrong? Thanks Mato --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David K.
2008-Mar-29 15:52 UTC
Re: Inheriting from AdminController intstead from ApplicationController
If AdminController is within admin/ I think your class name needs to include the namespace, Admin::AdminController. I''ve been putting together an ''admin'' section myself by doing this and that''s how I''ve been doing things. Hope this helps, I''ll keep my eye on this post to see how things go. Dave K. On Mar 28, 1:29 pm, milic <ilic.m...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi > > I would like to do the following: > > I have created an admin namespace and the required folders app/admin > views/admin etc. And then I wanted all controllers under app/admin to > inherit from a controller named AdminController which resists under > app/admin/admin.rb instead of inhereting from ApplicationController, > so I could better separate between admin and public section. The > AdminController looks like this: > > module Admin > class AdminController < ActionController::Base > include AuthenticatedSystem > helper :all > protect_from_forgery > layout ''admin/layouts/admin'' > end > end > > For testing the new namespace I created a GroupsController which looks > like this: > > require ''admin/admin'' > module Admin > class GroupsController < AdminController > def index > @groups = Group.find(:all) > end > end > end > > But every time I call the GroupsController I''m getting the following > error: > > uninitialized constant Admin::AdminController > > Can anybody tell me what I''m doing wrong? > > Thanks > Mato--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rajeshwar Mothe
2008-Mar-29 18:34 UTC
Re: Inheriting from AdminController intstead from ApplicationController
Hi I agree with Dave. You Have to include Admin::AdminController. I think this should be the trick,else reply to this post again. - Rajesh On Sat, Mar 29, 2008 at 9:22 PM, David K. <davidklaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > If AdminController is within admin/ I think your class name needs to > include the namespace, Admin::AdminController. I''ve been putting > together an ''admin'' section myself by doing this and that''s how I''ve > been doing things. > > Hope this helps, I''ll keep my eye on this post to see how things go. > > Dave K. > > On Mar 28, 1:29 pm, milic <ilic.m...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi > > > > I would like to do the following: > > > > I have created an admin namespace and the required folders app/admin > > views/admin etc. And then I wanted all controllers under app/admin to > > inherit from a controller named AdminController which resists under > > app/admin/admin.rb instead of inhereting from ApplicationController, > > so I could better separate between admin and public section. The > > AdminController looks like this: > > > > module Admin > > class AdminController < ActionController::Base > > include AuthenticatedSystem > > helper :all > > protect_from_forgery > > layout ''admin/layouts/admin'' > > end > > end > > > > For testing the new namespace I created a GroupsController which looks > > like this: > > > > require ''admin/admin'' > > module Admin > > class GroupsController < AdminController > > def index > > @groups = Group.find(:all) > > end > > end > > end > > > > But every time I call the GroupsController I''m getting the following > > error: > > > > uninitialized constant Admin::AdminController > > > > Can anybody tell me what I''m doing wrong? > > > > Thanks > > Mato > > >-- Happiness keeps u Sweet, Trials keep u Strong, Sorrow keeps u Human, Failure Keeps u Humble, Success keeps u Glowing, But only God Keeps u Going..... Keep Going..... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
milic
2008-Mar-29 20:44 UTC
Re: Inheriting from AdminController intstead from ApplicationController
Hi Thanks for your purposes but the problem still exists. The behaviour of the application has now changed. The first time I call a controller within the admin namespace it works fine, but when I reload the page the same error occurs again. By the way, is it possible to configure rails to load the admin.rb file automaticly every time a controller in the admin namespace is called (like application.rb)? Mato On Mar 29, 4:52 pm, "David K." <davidk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If AdminController is within admin/ I think your class name needs to > include the namespace, Admin::AdminController. I''ve been putting > together an ''admin'' section myself by doing this and that''s how I''ve > been doing things. > > Hope this helps, I''ll keep my eye on this post to see how things go. > > Dave K. > > On Mar 28, 1:29 pm, milic <ilic.m...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi > > > I would like to do the following: > > > I have created an admin namespace and the required folders app/admin > > views/admin etc. And then I wanted all controllers under app/admin to > > inherit from a controller named AdminController which resists under > > app/admin/admin.rb instead of inhereting from ApplicationController, > > so I could better separate between admin and public section. The > > AdminController looks like this: > > > module Admin > > class AdminController < ActionController::Base > > include AuthenticatedSystem > > helper :all > > protect_from_forgery > > layout ''admin/layouts/admin'' > > end > > end > > > For testing the new namespace I created a GroupsController which looks > > like this: > > > require ''admin/admin'' > > module Admin > > class GroupsController < AdminController > > def index > > @groups = Group.find(:all) > > end > > end > > end > > > But every time I call the GroupsController I''m getting the following > > error: > > > uninitialized constant Admin::AdminController > > > Can anybody tell me what I''m doing wrong? > > > Thanks > > Mato--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-Mar-29 23:03 UTC
Re: Inheriting from AdminController intstead from ApplicationController
Your controller rests under app/admin/admin.rb, which won''t be loaded automatically by rails because it doesn''t have a _controller suffix. I would suggest renaming this file to Admin::ApplicationController for its class and application_controller.rb as its file name, that way it will be automatically loaded and it will make sense what that controller''s supposed to be doing. -- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
milic
2008-Mar-29 23:26 UTC
Re: Inheriting from AdminController intstead from ApplicationController
This solution works, but with one disadvantage. Now when I call http://mydomain.com/admin/application, the Admin::ApplicationController is called which shouldn''t be possible. That''s why I originally wanted to build something like the normal ApplicationController, so this one can''t be called from outside. On 30 Mrz., 00:03, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Your controller rests under app/admin/admin.rb, which won''t be loaded > automatically by rails because it doesn''t have a _controller suffix. I would > suggest renaming this file to Admin::ApplicationController for its class and > application_controller.rb as its file name, that way it will be > automatically loaded and it will make sense what that controller''s supposed > to be doing. > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-Mar-30 01:22 UTC
Re: Inheriting from AdminController intstead from ApplicationController
If you''re really fussed with that, then define an index action in there that redirects people to where they should be. Not many people will be trying to go to admin/application unless they know it''s there. On Sun, Mar 30, 2008 at 9:56 AM, milic <ilic.mato-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > This solution works, but with one disadvantage. Now when I call > http://mydomain.com/admin/application, the > Admin::ApplicationController is called which shouldn''t be possible. > That''s why I originally wanted to build something like the normal > ApplicationController, so this one can''t be called from outside. > > On 30 Mrz., 00:03, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Your controller rests under app/admin/admin.rb, which won''t be loaded > > automatically by rails because it doesn''t have a _controller suffix. I > would > > suggest renaming this file to Admin::ApplicationController for its class > and > > application_controller.rb as its file name, that way it will be > > automatically loaded and it will make sense what that controller''s > supposed > > to be doing. > > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
s.ross
2008-Mar-30 02:47 UTC
Re: Inheriting from AdminController intstead from ApplicationController
On Mar 29, 2008, at 6:22 PM, Ryan Bigg (Radar) wrote:> If you''re really fussed with that, then define an index action in > there that redirects people to where they should be. Not many people > will be trying to go to admin/application unless they know it''s there. > > On Sun, Mar 30, 2008 at 9:56 AM, milic <ilic.mato-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > This solution works, but with one disadvantage. Now when I call > http://mydomain.com/admin/application, the > Admin::ApplicationController is called which shouldn''t be possible. > That''s why I originally wanted to build something like the normal > ApplicationController, so this one can''t be called from outside. > > On 30 Mrz., 00:03, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Your controller rests under app/admin/admin.rb, which won''t be > loaded > > automatically by rails because it doesn''t have a _controller > suffix. I would > > suggest renaming this file to Admin::ApplicationController for its > class and > > application_controller.rb as its file name, that way it will be > > automatically loaded and it will make sense what that controller''s > supposed > > to be doing.I''m wondering whether you''re trying to swim upstream with the inheritance approach inside a module. It seems you want to share some behaviors among your administrative controllers. Would a mixin work as well as direct inheritance here? E.g.: module Admin class AdminController < ApplicationController include KewlAdminMethods # ... end end Any chance that would solve your problem? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
milic
2008-Mar-30 10:36 UTC
Re: Inheriting from AdminController intstead from ApplicationController
Hi I think your right Ryan, not many people will try to go to admin/ applicaton. s.ross: This would cause the same problems, because this file would also not be loaded properly. Thank you guys for the help. Mato On 30 Mrz., 03:47, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 29, 2008, at 6:22 PM, Ryan Bigg (Radar) wrote: > > > > > If you''re really fussed with that, then define an index action in > > there that redirects people to where they should be. Not many people > > will be trying to go to admin/application unless they know it''s there. > > > On Sun, Mar 30, 2008 at 9:56 AM, milic <ilic.m...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > This solution works, but with one disadvantage. Now when I call > >http://mydomain.com/admin/application, the > > Admin::ApplicationController is called which shouldn''t be possible. > > That''s why I originally wanted to build something like the normal > > ApplicationController, so this one can''t be called from outside. > > > On 30 Mrz., 00:03, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > Your controller rests under app/admin/admin.rb, which won''t be > > loaded > > > automatically by rails because it doesn''t have a _controller > > suffix. I would > > > suggest renaming this file to Admin::ApplicationController for its > > class and > > > application_controller.rb as its file name, that way it will be > > > automatically loaded and it will make sense what that controller''s > > supposed > > > to be doing. > > I''m wondering whether you''re trying to swim upstream with the > inheritance approach inside a module. It seems you want to share some > behaviors among your administrative controllers. Would a mixin work as > well as direct inheritance here? E.g.: > > module Admin > class AdminController < ApplicationController > include KewlAdminMethods > # ... > end > end > > Any chance that would solve your problem?--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-Mar-30 10:47 UTC
Re: Inheriting from AdminController intstead from ApplicationController
Admin is not a module, it''s a namespace, Admin::ApplicationController. -- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
s.ross
2008-Mar-30 15:21 UTC
Re: Inheriting from AdminController intstead from ApplicationController
On Mar 30, 2008, at 3:47 AM, Ryan Bigg (Radar) wrote:> Admin is not a module, it''s a namespace, Admin::ApplicationController. > > -- > Ryan Bigg > http://www.frozenplague.netWhile the intent may be to create a namespace, it very much is a module. Here is the original code: module Admin class AdminController < ActionController::Base include AuthenticatedSystem helper :all protect_from_forgery layout ''admin/layouts/admin'' end end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---