1
<%= link_to (:controller => "company_stuff", :action => "index", :anchor => :menu), :class => 'links' do %>
    <li>Terms of Use</li>
<% end %>

I am having difficulty linking a page which is on a different controller and also the link is an anchor. Basically the controller is called company_stuff the action is index and the anchor is called #terms

Khaled
  • 2,101
  • 1
  • 18
  • 26
Muhammed Bhikha
  • 4,881
  • 9
  • 36
  • 47

2 Answers2

0

The problem was that the :controller :action :anchor was not being passed through as a hash, separate from the CSS class

Below is the solution

<%= link_to "Terms Of Use", {:controller => "company_stuff", :anchor => "terms"}, :class => "links" %>
Muhammed Bhikha
  • 4,881
  • 9
  • 36
  • 47
0

I believe you can try something like this

<%= link_to index_company_stuff_path + "#terms", :class => 'links' do %>
    <li>Terms of Use</li>
<% end %>

Or

<%= link_to index_company_stuffs_path + "#terms", :class => 'links' do %>
    <li>Terms of Use</li>
<% end %>

Depending on your controller name and route.

You can find more information on this question How to create an anchor and redirect to this specific anchor in Ruby on Rails

Community
  • 1
  • 1
MurifoX
  • 14,991
  • 3
  • 36
  • 60