Ruby on rails 轨道反向自动链接

Ruby on rails 轨道反向自动链接,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我的Rails应用程序中有以下代码: link_to('???',{:controller => 'profile', :action => 'show', :id => id}) 我想去掉“?”,并用它来显示动态生成的URL。我该怎么做?这有点像的功能,但我希望Rails将URL选项转换为文本,而不是相反。使用URL\u for()获取字符串 url_for({:controller => 'profile', :action => 'show', :id =&

我的Rails应用程序中有以下代码:

link_to('???',{:controller => 'profile', :action => 'show', :id => id})
我想去掉“?”,并用它来显示动态生成的URL。我该怎么做?这有点像的功能,但我希望Rails将URL选项转换为文本,而不是相反。

使用
URL\u for()
获取字符串

url_for({:controller => 'profile', :action => 'show', :id => id)}
在守则中:

url_hash = {:controller => 'profile', :action => 'show', :id => id}
link_to(url_for(url_hash), url_hash)
请参阅以获取主机名:

url_hash = {:controller => 'profile', :action => 'show', :id => id}
link_to("#{request.host_with_port}#{url_for(url_hash)}", url_hash)
从:

如果传递nil作为名称,则链接本身的值将成为名称


如果链接将转换为文本,那么它将如何被点击?
link_to(nil,{:controller => 'profile', :action => 'show', :id => id})