Forum: Ruby on Rails 1 layous for application with modules

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David Durham (Guest)
on 2006-03-24 22:40
(Received via mailing list)
Hi all,

New to list.  Just read, Agile Web D. 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
Brian H. (Guest)
on 2006-03-25 00:11
(Received via mailing list)
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.
John D. (Guest)
on 2006-03-25 08:03
(Received via mailing list)
David Durham wrote:
> <%= link_to 'List', :controller => 'report', :action => 'list' -%>
>     <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/ActionControlle...

Regards,
John
This topic is locked and can not be replied to.