Reputation: 5009
In my Rails 3 app I have a link_to
that takes the User from their profile page to the settings page. The settings page contains a form :partial
for editing a profile. What I'd like to do is have the link_to
in the Profile take the User to an anchor in the form partial. I've given it a go but am having trouble.
As my link_to
I have:
<%= link_to('Visit the info section', settings_path, {:anchor => 'info'}) %>
Within settings_path is <%= render :partial => 'profiles/edit_settings_form' %>
Within that partial is:
<div class="infoBlock" anchor="#info">
</div>
I have a route for settings that I thought was causing the error:
match "/settings" => "settings#show", :as => 'settings'
I tried adding another match for the anchor to "profiles#edit_settings_form" but it didn't work. Any ideas?
Upvotes: 1
Views: 998
Reputation: 8631
<div class="infoBlock" anchor="#info">
is not proper way to do an anchor to a page. Correct syntax is something similar:
<a name="anchor"></a>
Now when you got to page with pagename#anchor, it redirects you to that block. For example:
<%= link_to "Block in home", :action => "home", :anchor => "anchor" %>
Upvotes: 3