create a link_to in controller

旧巷老猫 提交于 2019-12-03 03:19:36

if you are using rails 3, you can use view_context.link_to(...) in your controller.

UPDATE: with the format.html code

format.html do
  redirect_to purchase_order_headers_path, notice: "PO already has RR with RR ID: #{view_context.link_to(rr.rr_id, receiving_record_header_path(rr.id))} void RR first.".html_safe
end

Use #{ActionController::Base.helpers.link_to 'rr.rr_id', '/url'}.html_safe

To make link in your controllers. To have the string display as html (instead of being escaped), call the html_safe method on the string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!