I''m working on building an administration (cms) system for websites that I manage. I''m trying my best to stick to the RESTful concepts, so right now I have my controllers structured like this: -app --controllers ----news_stories_controller.rb <-- Manage news stories (administration system) ----news_controller.rb <-- View news stories (public side) ----calendar_events_controller.rb <-- Manage calendar events (administration system) ----calendar_controller.rb <-- View calendar events (public side) Note that in my routes.rb I prefix all the "administration system" controllers with ''/admin''. Would it make more sense to re-factor this to use modules (namespaces) so it would be structured like this? -app --controllers ----admin ------news.rb <-- Manage news stories ------calendar.rb <-- Manage calendar events ----news.rb <-- View news stories ----calendar.rb <-- View calendar events I''ve heard a lot of bad things about modules, but it seems like most of the problems come down to naming conflicts when you''re dealing with namespaced models. I much prefer the module approach because it keeps everything separated and organized...what do you guys think? Andrew -- 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 -~----------~----~----~----~------~----~------~--~---
There is an excellent discusison on namespaces in AWDwR book. You will basically have two different directories containing the same class name but the namespace will be distinguised by using the :: operator. On 10/15/06, Andrew Hite <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m working on building an administration (cms) system for websites that > I manage. I''m trying my best to stick to the RESTful concepts, so right > now I have my controllers structured like this: >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Andrew Hite wrote:> I''ve heard a lot of bad things about modules, but it seems like most of > the problems come down to naming conflicts when you''re dealing with > namespaced models.It''s all FUD. I haven''t experienced any problems using controller modules. I''m not sure what "namespaced models" are. Joe -- 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 -~----------~----~----~----~------~----~------~--~---
Joe Ruby MUDCRAP-CE wrote:> Andrew Hite wrote: > >> I''ve heard a lot of bad things about modules, but it seems like most of >> the problems come down to naming conflicts when you''re dealing with >> namespaced models. > > It''s all FUD. I haven''t experienced any problems using controller > modules. I''m not sure what "namespaced models" are. > > JoeIt is what it is. In my experience, a number of plugins, especially but by no means only ones involved in authentication and authorization, have problems with namespaced controllers. One of my early apps was built with controller modules for Admin::* operations, but the time spent dealing with the problems eventually became enough of an annoyance that I got rid of the hierarchy and flattened out my controllerspace. Getting work done is more imporant to me than a fixation on Code Esthetics, and if I really had that many admin controllers I wanted to segregate, I suppose I could prefix them and their corresponding helpers and view directories with "admin_". YMMV. :) -- 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 -~----------~----~----~----~------~----~------~--~---
Steve Koppelman wrote:> It is what it is. In my experience, a number of plugins, especially but > by no means only ones involved in authentication and authorization, have > problems with namespaced controllers. One of my early apps was built > with controller modules for Admin::* operations, but the time spent > dealing with the problems eventually became enough of an annoyance that > I got rid of the hierarchy and flattened out my controllerspace. Getting > work done is more imporant to me than a fixation on Code Esthetics, and > if I really had that many admin controllers I wanted to segregate, I > suppose I could prefix them and their corresponding helpers and view > directories with "admin_". > > YMMV. :)Hmm, yeah, I guess if I had some plugins I couldn''t live without (which I don''t -- I''ve checked out all the member/user plugins and didn''t like any of them). But then I''d say the plugin author is to blame for not working with namespaced controllers, and maybe I''d even also try to get it to work with namespaced controllers. I just looove how namespaced controllers keep individual files simple. Joe -- 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 -~----------~----~----~----~------~----~------~--~---
Joe Ruby MUDCRAP-CE wrote:> Andrew Hite wrote: > >> I''ve heard a lot of bad things about modules, but it seems like most of >> the problems come down to naming conflicts when you''re dealing with >> namespaced models. > > It''s all FUD. I haven''t experienced any problems using controller > modules. I''m not sure what "namespaced models" are. > > JoeI actually did some playing with namespaced controllers (modules) last night and ended up running into some problems after-all...so I think I''m going to stay away from the whole concept. I prefer REST over RPC, and there are some big compatibility problems with the simply_restful support in edge rails and namespaces. I figure I''ll just stick with using before_filters on specific actions as opposed to separating everything out. Andrew -- 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 -~----------~----~----~----~------~----~------~--~---
Andrew Hite wrote:> Joe Ruby MUDCRAP-CE wrote: >> Andrew Hite wrote: >> >>> I''ve heard a lot of bad things about modules, but it seems like most of >>> the problems come down to naming conflicts when you''re dealing with >>> namespaced models. >> >> It''s all FUD. I haven''t experienced any problems using controller >> modules. I''m not sure what "namespaced models" are. >> >> Joe > > I actually did some playing with namespaced controllers (modules) last > night and ended up running into some problems after-all...so I think I''m > going to stay away from the whole concept. I prefer REST over RPC, and > there are some big compatibility problems with the simply_restful > support in edge rails and namespaces. I figure I''ll just stick with > using before_filters on specific actions as opposed to separating > everything out. > > AndrewI''m curious -- what problems specifically? I haven''t really messed around with web services yet. If there are conflicts with controller namespaces, I''m sure Rails core would like to hear about them (i.e. tickets). Joe -- 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 -~----------~----~----~----~------~----~------~--~---
Joe Ruby MUDCRAP-CE wrote:> Andrew Hite wrote: >> Joe Ruby MUDCRAP-CE wrote: >>> Andrew Hite wrote: >>> >>>> I''ve heard a lot of bad things about modules, but it seems like most of >>>> the problems come down to naming conflicts when you''re dealing with >>>> namespaced models. >>> >>> It''s all FUD. I haven''t experienced any problems using controller >>> modules. I''m not sure what "namespaced models" are. >>> >>> Joe >> >> I actually did some playing with namespaced controllers (modules) last >> night and ended up running into some problems after-all...so I think I''m >> going to stay away from the whole concept. I prefer REST over RPC, and >> there are some big compatibility problems with the simply_restful >> support in edge rails and namespaces. I figure I''ll just stick with >> using before_filters on specific actions as opposed to separating >> everything out. >> >> Andrew > > I''m curious -- what problems specifically? I haven''t really messed > around with web services yet. If there are conflicts with controller > namespaces, I''m sure Rails core would like to hear about them (i.e. > tickets). > > JoeThe main thing that was annoying me is that the named routes that simply_restful generates were acting strange...I''ll have to test it out again tomorrow to replicate the problem - I don''t recall exactly what the error was. It may have been something I did wrong, but all I did was move my controllers into an admin::* namespace and set the resource path_prefix to ''/admin'', which seemed like the logical thing to do. -- 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 -~----------~----~----~----~------~----~------~--~---