2009-12-11 15 views
6

कैसे मैं एक LINK_TO एक पृष्ठ पर किसी विशिष्ट (html) आईडी पर जाने के लिए inorder प्रयोग करते हैं सामान्य रूप से मैं इस्तेमाल कर सकते हैं अगर मैं एक पृष्ठ पर "whatever_id" जाना चाहती थीरूबी ऑन रेल्स आंतरिक आईडी LINK_TO

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

लेकिन मैं अपने LINK_TO

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

सहायक तरीकों का उपयोग करना चाहते हैं। क्या किसी को भी यह करना आता है? क्या यह संभव है?

रेल 2.3.4

उत्तर

26

LINK_TO एक यूआरएल के लिए लंगर जोड़ सकते हैं।

documentation से,

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

अपने मामले तो आप शायद चाहते हैं,

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

धन्यवाद, एक आकर्षण की तरह काम किया !! – Schneems

संबंधित मुद्दे