2010-11-23 6 views
14

redirect_to에 추가 할 해시를 지정해야합니다. 어떻게해야합니까?레일즈 - redirect_to에 해시 추가

이 내 redirect_to 형성하는 방법이다 :

redirect_to :action => 'show', :id => @consultant.id 

나는

감사를 example.com/consultant/#some_hash로 이동합니다!

답변

5

http://api.rubyonrails.org/classes/ActionDispatch/Routing/UrlFor.html#method-i-url_forredirect_to your_current_options, :anchor => 'fragment_identifier' 나는 비슷한 문제가 있었다보십시오. 나는 이것을 시도했다 :

redirect_to @post, anchor: 'tab_items' 

그러나 레일 4.2.6을 사용하지는 않았다. 하지만 다음과 같이 변경하면 이제는 잘 작동합니다.

redirect_to post_path(@post, anchor: 'tab_items') 
+0

답변으로 표시해야합니다. –

관련 문제