【发布时间】:2010-11-23 12:16:52
【问题描述】:
我需要指定一个散列来添加到redirect_to。我该怎么做?
这就是我的redirect_to 的形成方式:
redirect_to :action => 'show', :id => @consultant.id
我需要访问 example.com/consultant/#some_hash
谢谢!
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3
我需要指定一个散列来添加到redirect_to。我该怎么做?
这就是我的redirect_to 的形成方式:
redirect_to :action => 'show', :id => @consultant.id
我需要访问 example.com/consultant/#some_hash
谢谢!
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3
试试redirect_to your_current_options, :anchor => 'fragment_identifier'
http://api.rubyonrails.org/classes/ActionDispatch/Routing/UrlFor.html#method-i-url_for
【讨论】:
我遇到了类似的问题。我试过这个:
redirect_to @post, anchor: 'tab_items'
但不能使用 rails 4.2.6。但是,如果我更改为以下内容,并且现在可以正常工作:
redirect_to post_path(@post, anchor: 'tab_items')
【讨论】: