ruby on rails - anchor tag in link_to -


found difficult frame question, here's problem.

alert.html

<div class="alert_text">  <%= link_to "comment", :action=>:show, :id=>lp.id %> </div> 

when click on link takes me show page

show.html

table displayed @ beginning of page after that, below part of code.

 <div id="comments">   <%= render :partial=>'comments' %>  </div> 

what need is, when click on link comment must load show page normal should direct comments part of page.

edit: happens in stackoverflow.com, on top left stackexchange when click on inbox message.

it sounds want anchor option path helper. assuming you're using restful routing, should able like:

<%= link_to "comments", my_model_path(lp, anchor: 'comments') %> 

you need change my_model whatever resource called. if have resources :articles in routes.rb, article_path(lp, anchor: 'comments')


Comments