打印整个演出路径
我正在 Rails 中构建提要,我希望在内容部分中返回我的项目的整个显示路径。我当前的代码仅打印没有根的路径。
entry.content link_path(link)
返回类似 links/44 的内容,但我想返回 http://www.example.com/links/44。使用托管应用程序的根目录。感谢您的任何帮助。
atom_feed do |feed|
feed.title "Wrld"
feed.updated @links.first.created_at
@links.each do |link|
feed.entry link do |entry|
entry.title link.title
entry.content link_path(link), :type => 'html'
entry.author do |author|
author.name "Wrld"
end
end
end
end
更新
谢谢 Leonid,link_url(link) 做到了
I'm constructing a feed in rails and I would like the entire show path for my items to be returned in the content portion. My current code only prints the path without the root.
entry.content link_path(link)
returns something like links/44 but I would like to return http://www.example.com/links/44. Using the root of wherever the app is being hosted. Thanks for any help.
atom_feed do |feed|
feed.title "Wrld"
feed.updated @links.first.created_at
@links.each do |link|
feed.entry link do |entry|
entry.title link.title
entry.content link_path(link), :type => 'html'
entry.author do |author|
author.name "Wrld"
end
end
end
end
UPDATE
Thanks Leonid, link_url(link) did it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
link_url
就是您要查找的内容。一般来说,任何带有_path
的路由助手都会返回路径部分,而_url
助手会返回整个 URL。link_url
is what you're looking for. In general any route helper with_path
returns the path part and the_url
helper returns the entire URL.