I haven''t come across an obvious best way to write my administrative functions. Some candidates are: - Put the admin functions amongst the standard authenticated user functionality of the site, following the REST approach until your dying breath, and using roles to expose/hide these functions - Write admin controllers in an admin:: namespace, with their own administrative-specific views - Write a separate admin application entirely, using the same models, and stick the admin app on a subdomain Each solution has its pros and cons. Certainly someone has opinions regarding this; can you convince me/give me instruction as to your fondest approach? -- 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''d like to second this question... I was searching around before posting this question myself. I have seen posts like this online, http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails - saying that you shouldn''t use namespacing. What would doing it using rails routes look like instead? Thoughts? On Sep 29, 7:17 pm, Sebastian Mathews <rails-mailing-l...@andreas- s.net> wrote:> I haven''t come across an obvious best way to write my administrative > functions. Some candidates are: > - Put the admin functions amongst the standard authenticated user > functionality of the site, following the REST approach until your dying > breath, and using roles to expose/hide these functions > - Write admin controllers in an admin:: namespace, with their own > administrative-specific views > - Write a separate admin application entirely, using the same models, > and stick the admin app on a subdomain > > Each solution has its pros and cons. Certainly someone has opinions > regarding this; can you convince me/give me instruction as to your > fondest approach? > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
There''s a namespace routing feature in the 2.0 preview release. DHH''s blog post about the changes in 2.0 (http://weblog.rubyonrails.org/2007/9/30/rails-2-0-0-preview-release) has a short example of how to use it for admin interfaces. -- 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''d stay away from the admin:: namespace, at least if you are ever going to use nested resources. I just spent the weekend refactoring an application that had been using that namespace, but then I needed nested resources and WHAM... no good. DHH''s comments about map.namespaces looks promising, though it seems you could easily do something similar with an empty AdminController and nested resources. On Sep 29, 6:17 pm, Sebastian Mathews <rails-mailing-l...@andreas- s.net> wrote:> I haven''t come across an obvious best way to write my administrative > functions. Some candidates are: > - Put the admin functions amongst the standard authenticated user > functionality of the site, following the REST approach until your dying > breath, and using roles to expose/hide these functions > - Write admin controllers in an admin:: namespace, with their own > administrative-specific views > - Write a separate admin application entirely, using the same models, > and stick the admin app on a subdomain > > Each solution has its pros and cons. Certainly someone has opinions > regarding this; can you convince me/give me instruction as to your > fondest approach? > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Matt Grayson wrote:> There''s a namespace routing feature in the 2.0 preview release. DHH''s > blog post about the changes in 2.0 > (http://weblog.rubyonrails.org/2007/9/30/rails-2-0-0-preview-release) > has a short example of how to use it for admin interfaces.I will need admin functionality in a few upcoming projects and am running into the same questions for where it should go. I thought of creating a separate Rails app to use on an admin subdomain, but that seems like overkill. I noticed in the inline documentation for the Controller generator (script/generate controller --help) that it mentioned the ability to "create a controller within a module," but I couldn''t find any further info on what a "module" was in this regard? Here''s the exact text: # script/generate controller --help Description: The controller generator creates stubs for a new controller and its views. The generator takes a controller name and a list of views as arguments. The controller name may be given in CamelCase or under_score and should not be suffixed with ''Controller''. To create a controller within a module, specify the controller name as ''module/controller''. The generator creates a controller class in app/controllers with view templates in app/views/controller_name, a helper class in app/helpers, and a functional test suite in test/functional. Example: ./script/generate controller CreditCard open debit credit close Credit card controller with URLs like /credit_card/debit. Controller: app/controllers/credit_card_controller.rb Views: app/views/credit_card/debit.rhtml [...] Helper: app/helpers/credit_card_helper.rb Test: test/functional/credit_card_controller_test.rb Modules Example: ./script/generate controller ''admin/credit_card'' suspend late_fee Credit card admin controller with URLs /admin/credit_card/suspend. Controller: app/controllers/admin/credit_card_controller.rb Views: app/views/admin/credit_card/debit.rhtml [...] Helper: app/helpers/admin/credit_card_helper.rb Test: test/functional/admin/credit_card_controller_test.rb So is "module" just another term for the namespace approach that has been mentioned above? Can anyone provide an example of using this? And even though DHH''s post re: Rails 2.0 has some text that points to a new solution, what is a viable solution for the 1.x line? -- 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 -~----------~----~----~----~------~----~------~--~---
Chris Bloom wrote:> So is "module" just another term for the namespace approach that has > been mentioned above? Can anyone provide an example of using this?I believe so. The biggest reason namespacing controllers is often frowned upon is that it can add unnecessary complexity to your app.> And even though DHH''s post re: Rails 2.0 has some text that points to a > new solution, what is a viable solution for the 1.x line?The simplest thing you can do with 1.x is: <code> map.resources :whatever, :path_prefix => ''/admin'' </code> -- 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 -~----------~----~----~----~------~----~------~--~---
Matt Grayson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Chris Bloom wrote: > > So is "module" just another term for the namespace approach that has > > been mentioned above? Can anyone provide an example of using this? > > I believe so. The biggest reason namespacing controllers is often > frowned upon is that it can add unnecessary complexity to your app.Yes. Modules and namespaces are synonymous. I''ve posted a sample application at http://dev.panesofglass.org/projects/contacts.zip. This app is using a contacts namespace to enclose a PeopleController and CompaniesController. I can''t get the functional tests to work, so any help there would be appreciated. The good news is that you can indeed create nested resources now.> > And even though DHH''s post re: Rails 2.0 has some text that points to a > > new solution, what is a viable solution for the 1.x line? > > The simplest thing you can do with 1.x is: > > <code> > map.resources :whatever, :path_prefix => ''/admin'' > </code>That''s definitely the easiest approach. It lets you continue to use all the regular methods of referencing paths and urls without having to edit every object, @object, object_path or object_url reference in your app. Of course, if you''re going for a more modular approach and you don''t scaffold then you probably don''t mind writing that from scratch. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
As to my testing issues, I think my solution will be to use RSpec, which I''ve already planned to use in the future. However, if you want to use the built in testing system, not sure what to tell you. I''d still be interested to see if anyone knows how to write tests for namespaced controllers. On Oct 1, 11:45 am, riles01 <ryan.ri...-75D+SkCOd7Z46IMFfmbxvA@public.gmane.org> wrote:> Matt Grayson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > Chris Bloom wrote: > > > So is "module" just another term for the namespace approach that has > > > been mentioned above? Can anyone provide an example of using this? > > > I believe so. The biggest reason namespacing controllers is often > > frowned upon is that it can add unnecessary complexity to your app. > > Yes. Modules and namespaces are synonymous. I''ve posted a sample > application athttp://dev.panesofglass.org/projects/contacts.zip. This > app is using a contacts namespace to enclose a PeopleController and > CompaniesController. I can''t get the functional tests to work, so any > help there would be appreciated. The good news is that you can indeed > create nested resources now. > > > > And even though DHH''s post re: Rails 2.0 has some text that points to a > > > new solution, what is a viable solution for the 1.x line? > > > The simplest thing you can do with 1.x is: > > > <code> > > map.resources :whatever, :path_prefix => ''/admin'' > > </code> > > That''s definitely the easiest approach. It lets you continue to use > all the regular methods of referencing paths and urls without having > to edit every object, @object, object_path or object_url reference in > your app. Of course, if you''re going for a more modular approach and > you don''t scaffold then you probably don''t mind writing that from > scratch.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---