2009-12-11 12 views
6

¿Cómo uso un link_to finde para ir a una identificación específica (html) en una página normalmente si quería ir a la "whatever_id" en una página que podría utilizarRuby on Rails link_to ID interno

<a href="http://www.example.com/index/mypage#whatever_id>Click Here</a> 

pero me gustaría usar mi link_to

<%= link_to "click here" , {:action => "mypage", :controller => "index" }, :id => "#whatever_id"%> 

métodos de ayuda. ¿Alguien sabe como hacer esto? ¿Es posible?

Rails 2.3.4

Respuesta

26

link_to pueden agregar anclas a una URL.

Desde el documentation,

link_to "Comment wall", profile_path(@profile, :anchor => "wall") 
# => <a href="/profiles/1#wall">Comment wall</a> 

En su caso es probable que desee,

<%= link_to "click here" , {:action => "index", :controller => "mypage", :anchor => "whatever" } %> 
+0

Gracias, funcionó de maravilla !! – Schneems