1 layous for application with modules

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

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.

David Durham wrote:

<%= link_to ‘List’, :controller => ‘report’, :action => ‘list’ -%>
Applications

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 :slight_smile:

http://api.rubyonrails.com/classes/ActionController/Base.html#M000174

Regards,
John

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs