Rabbit
2006-Jan-25 06:36 UTC
[Rails] Routes working with subdirectories repeat subdirectory...
Hi all. Views associated with admin controllers must always specify both :controller and :action when using link_to. Example: <%= link_to ''Edit'', { :controller => ''/raid_manager'', :action => ''edit_raid_template'', :id => raid_template.id } %> The above is being called from within the Admin::RaidManagerController. The controller was generated by using the Rails generate script, with a filename argument of "admin/RaidManager". Whenever I use that format, it prepends Admin:: to my class name - why? I know :: is the scope resolution operator, but there''s scarce documentation about, even in the pick axe book. (That''s more of an aside question.) If I use link_to without specifying the controller, the link itself works, but then I get something like: xyz.com/admin/admin/raid_manager/edit_raid_template It repeats the admin part. I also get the same effect even if I DO include the controller without the preceeeding /. The routes that handle the admin area looks like: map.connect ''/admin/'', :controller => ''admin/news_manager'' map.connect ''/admin/:controller/:action/:id'' I don''t like having to continually reference the controller, and I feel like I shouldn''t have to. Also, I''ve found I''m unable to break out of the admin/... URL once I''m in it.So like if I were to log out, and redirect someone to :controller => ''pages'', it would still look like admin/pages. ARGH! - Rabbit -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060125/5bbd4441/attachment.html
Rabbit
2006-Jan-25 07:02 UTC
[Rails] Re: Routes working with subdirectories repeat subdirectory...
That''s interesting. If I get rid of the routing rule, standard link_to''s work fine. I know this will come back to haunt me though. =/ - Rabbit --- On 1/24/06, Rabbit <rabbitblue@gmail.com> wrote:> > Hi all. > > Views associated with admin controllers must always specify both > :controller and :action when using link_to. > > Example: > > <%= link_to ''Edit'', { :controller => ''/raid_manager'', :action => > ''edit_raid_template'', :id => raid_template.id } %> > > The above is being called from within the Admin::RaidManagerController. > The controller was generated by using the Rails generate script, with a > filename argument of "admin/RaidManager". Whenever I use that format, it > prepends Admin:: to my class name - why? I know :: is the scope resolution > operator, but there''s scarce documentation about, even in the pick axe book. > (That''s more of an aside question.) > > If I use link_to without specifying the controller, the link itself works, > but then I get something like: > > xyz.com/admin/admin/raid_manager/edit_raid_template > > It repeats the admin part. I also get the same effect even if I DO include > the controller without the preceeeding /. > > The routes that handle the admin area looks like: > > map.connect ''/admin/'', :controller => ''admin/news_manager'' > map.connect ''/admin/:controller/:action/:id'' > > I don''t like having to continually reference the controller, and I feel > like I shouldn''t have to. Also, I''ve found I''m unable to break out of the > admin/... URL once I''m in it.So like if I were to log out, and redirect > someone to :controller => ''pages'', it would still look like admin/pages. > ARGH! > > - Rabbit >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060125/195fece3/attachment-0001.html