Just a thought, that this can be simplified by guessing the namespace of the controller or the params[:controller] class Admin::Users < ApplicationController end params[:controller]=>''admin/users'' Most use cases fall with in this context, don''t they? Excuse me, if I come across as a complete idiot, this is the first time am looking at the edge, resources and url helpers. Certainly, I felt the pain while trying to pass [:admin, @user] for so many url helpers. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 10/12/07, blj <braghavan@gmail.com> wrote:> > > Excuse me, if I come across as a complete idiot, this is the first > time am looking at the edge, resources and url helpers. Certainly, I > felt the pain while trying to pass [:admin, @user] for so many url > helpers.So, you want to be able to call url_for(@user) and that Rails guesses that it is in the :admin namespace because the current controller is "admin/users". I felt this pain of context insensitivity too, but if you have User resource outside of admin namespace, how would you refer to it then? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Referring it outside the context makes sense to add [:admin, @user] which is intuitive. While coding that we realise we are outside the context. Also guessing instead of fixing it in the code, helps in moving the controller to a different name space easier. On Oct 12, 1:55 pm, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> On 10/12/07, blj <bragha...@gmail.com> wrote: > > > > > Excuse me, if I come across as a complete idiot, this is the first > > time am looking at the edge, resources and url helpers. Certainly, I > > felt the pain while trying to pass [:admin, @user] for so many url > > helpers. > > So, you want to be able to call url_for(@user) and that Rails guesses that > it is in the :admin namespace because the current controller is > "admin/users". I felt this pain of context insensitivity too, but if you > have User resource outside of admin namespace, how would you refer to it > then?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
may be it can be url_for (@user, :in=>:admin) On Oct 12, 1:55 pm, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> On 10/12/07, blj <bragha...@gmail.com> wrote: > > > > > Excuse me, if I come across as a complete idiot, this is the first > > time am looking at the edge, resources and url helpers. Certainly, I > > felt the pain while trying to pass [:admin, @user] for so many url > > helpers. > > So, you want to be able to call url_for(@user) and that Rails guesses that > it is in the :admin namespace because the current controller is > "admin/users". I felt this pain of context insensitivity too, but if you > have User resource outside of admin namespace, how would you refer to it > then?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---