Hi all, New to list. Just read, Agile Web Development with Rails -- good book. Ok, on to my question. I''d like to use a single layout for my entire application, but I also want to use modules. This may be a mistake, but I''m also just kind of curious how to link properly in this case. So, for instance, I''ve code like this my layout: <%= link_to ''List'', :controller => ''report'', :action => ''list'' -%> <%= link_to ''Applications'', :controller => ''admin/application'', :action => ''list'' -%> When I go to the admin module, here''s what is rendered: <a href="/admin/report/list">List</a> <a href="/admin/admin/application/list">Applications</a> So, anyway to make link_to "module aware?" Perhaps I''m just doing something wrong. Thanks, Dave
Try <%= link_to ''Applications'', :controller => ''/admin/application'', :action => ''list'' -%> and see if that does it for you. I''m doing exactly that in my app and it seems to work. You might also want to look at named routes instead. On 3/24/06, David Durham <ddurham@vailsys.com> wrote:> > Hi all, > > New to list. Just read, Agile Web Development with Rails -- good book. > Ok, on to my question. > > I''d like to use a single layout for my entire application, but I also > want to use modules. This may be a mistake, but I''m also just kind of > curious how to link properly in this case. So, for instance, I''ve code > like this my layout: > > <%= link_to ''List'', :controller => ''report'', :action => ''list'' -%> > > <%= link_to ''Applications'', :controller => ''admin/application'', :action > => ''list'' -%> > > > When I go to the admin module, here''s what is rendered: > > > <a href="/admin/report/list">List</a> > > <a href="/admin/admin/application/list">Applications</a> > > So, anyway to make link_to "module aware?" Perhaps I''m just doing > something wrong. > > Thanks, > > Dave > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/8c509699/attachment.html
David Durham wrote:> Hi all, > > New to list. Just read, Agile Web Development with Rails -- good > book. Ok, on to my question. > > I''d like to use a single layout for my entire application, but I also > want to use modules. This may be a mistake, but I''m also just kind of > curious how to link properly in this case. So, for instance, I''ve > code like this my layout: > > <%= link_to ''List'', :controller => ''report'', :action => ''list'' -%> > > <%= link_to ''Applications'', :controller => ''admin/application'', > :action => ''list'' -%> > > > When I go to the admin module, here''s what is rendered: > > > <a href="/admin/report/list">List</a> > > <a href="/admin/admin/application/list">Applications</a> > > So, anyway to make link_to "module aware?" Perhaps I''m just doing > something wrong. >I just struggled with this earlier today and found there is a nice solution, in the link_to :options, you need to specify :only_path => true I''ve found that searching through the API docs takes a bit of work, but the results are worth it, because there is no better answer than the actual source code docs :-) http://api.rubyonrails.com/classes/ActionController/Base.html#M000174 Regards, John
Possibly Parallel Threads
- absolute urls in url_for vs. link_to
- Link_to :protocol and :host?
- Setting :canvas => false for URL generation doesn''t always work?
- How do you get link_to to work correctly when using subdomains as account keys?
- [newbie]how to use link_to to link to another controller?