I''m having some issues with routing when using controllers in sub-folders. I have controllers in an admin folder that look like this: class Admin::UsersController < ApplicationController end My link_to_remote calls look like this: <%= link_to_remote ''Users'', :url => { :controller => ''admin/users'', :action => :index } %> And then when I deploy to production I get errors such as: ActionView::MissingTemplate (Missing template admin/users.erb in view path /rails/myapp/releases/20090203200508/app/views:): In production it asks for the wrong template. It should be asking for the template app/views/admin/users/index.html.erb like it does in development. I found if I add a route: map.connect ''admin/users'', :controller => ''admin/users'', :action => ''index'' my link_to_remote calls do begin to work in both development and production. I do not want to add a route for every single url I have in my admin. What''s the solution? Using Rails 2.2.2. Thanks, -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
On Tue, Feb 3, 2009 at 2:18 PM, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I do not want to add a route for every single url I have in my admin.Also, forgot to mention.. I tried this: map.connect ''admin/:controller/:action/:id'' But I didn''t see any change. Thanks, -- Greg Donald http://destiney.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 don''t think you can supply :controller => "some_controller" in link_to_remote, only :action and :id are valid. I think you should embrace the resourceful way of doing things and add this to your routes.rb file: map.resources :users, :controller => ''admin/users'', :name_prefix => ''admin_'' This would then give you many clean named routes, one of which is admin_users_path which will link to what you want. Now you can put: :url => admin_users_path I have not tested this, but I''m pretty sure it will work. On Feb 3, 3:20 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Feb 3, 2009 at 2:18 PM, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I do not want to add a route for every single url I have in my admin. > > Also, forgot to mention.. I tried this: > > map.connect ''admin/:controller/:action/:id'' > > But I didn''t see any change. > > Thanks, > > -- > Greg Donaldhttp://destiney.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Feb 3, 2009 at 3:20 PM, Daly <aeldaly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t think you can supply :controller => "some_controller" in > link_to_remote,I have about half-a-dozen Rails apps that say otherwise :)> only :action and :id are valid. I think you should > embrace the resourceful way of doing things and add this to your > routes.rb file:I do not want resources. I just want routes that work without adding an entry for each url in routes.rb.> map.resources :users, :controller => ''admin/users'', :name_prefix => > ''admin_'' > > This would then give you many clean named routes, one of which is > admin_users_path which will link to what you want. Now you can put: > > :url => admin_users_path > > I have not tested this, but I''m pretty sure it will work.Yes, it will, but that''s not what I want for this app. I just want my admin controllers in a folder, that''s it. Thanks all the same. -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2009-Feb-03 23:59 UTC
Re: controllers/views in sub-folders and broken routes
Ah if only merb''s routes were in rails already Anyway, what OTHER routes do you have in front of the default route? Coz when you''re using namespaces controllers, it matters. Aside from this, DHH has made it pretty clear this isn''t a great thing to do. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 04/02/2009, at 7:20 AM, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Tue, Feb 3, 2009 at 2:18 PM, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I do not want to add a route for every single url I have in my admin. > > Also, forgot to mention.. I tried this: > > map.connect ''admin/:controller/:action/:id'' > > But I didn''t see any change. > > > Thanks, > > > > -- > Greg Donald > http://destiney.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 -~----------~----~----~----~------~----~------~--~---
On Tue, Feb 3, 2009 at 5:59 PM, Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote:> Anyway, what OTHER routes do you have in front of the default route? > Coz when you''re using namespaces controllers, it matters. Aside from > this, DHH has made it pretty clear this isn''t a great thing to do.Having a single admin controller with 807345029 lines of code in it clearly isn''t a great thing to do either. -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2009-Feb-05 00:18 UTC
Re: controllers/views in sub-folders and broken routes
No, but putting admin_ in front of your admin controllers is fine. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 7:32 AM, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Tue, Feb 3, 2009 at 5:59 PM, Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org > > wrote: >> Anyway, what OTHER routes do you have in front of the default route? >> Coz when you''re using namespaces controllers, it matters. Aside from >> this, DHH has made it pretty clear this isn''t a great thing to do. > > > Having a single admin controller with 807345029 lines of code in it > clearly isn''t a great thing to do either. > > > > -- > Greg Donald > http://destiney.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 -~----------~----~----~----~------~----~------~--~---
On Wed, Feb 4, 2009 at 6:18 PM, Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote:> > No, but putting admin_ in front of your admin controllers is fine.That''s not very DRY. -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2009-Feb-06 03:09 UTC
Re: controllers/views in sub-folders and broken routes
So use a loop with send to map LOL. A class def is only ruby after all Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 06/02/2009, at 5:28 AM, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Wed, Feb 4, 2009 at 6:18 PM, Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org > > wrote: >> >> No, but putting admin_ in front of your admin controllers is fine. > > That''s not very DRY. > > > -- > Greg Donald > http://destiney.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 -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2009-Feb-06 03:13 UTC
Re: controllers/views in sub-folders and broken routes
Here''s what I do in my app %w[wip businesses people journal microsites brief reports search].each do |controller_name| map.connect "admin/#{controller_name}/:action/:id", :controller => "admin_#{controller_name}" end I''m sure you could probably do something like this, too, tho it''s untested: %w[wip businesses people journal microsites brief reports search].each do |controller_name| map.connect "admin/#{controller_name}/:action/:id", :controller => "admin/#{controller_name}" end On 06/02/2009, at 5:28 AM, Greg Donald wrote:> > On Wed, Feb 4, 2009 at 6:18 PM, Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org > > wrote: >> >> No, but putting admin_ in front of your admin controllers is fine. > > That''s not very DRY. > > > -- > Greg Donald > http://destiney.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 -~----------~----~----~----~------~----~------~--~---