Rails rails 能不能在 model 中使用 link_to 方法

lb563 · March 20, 2012 · Last by nouse replied at March 20, 2012 · 2191 hits

现在想在 model 这边组装数据,直接在 model 中使用 link_to 方法,这个可以实现吗?

不能,而且也不应该

SHOCKING HORRRRROR!!! o_O

#2 楼 @fredwu 最近 2 楼这个表情很流行?o_0 原版

后果自负

include ActionView::Helpers::UrlHelper
def temp
  link_to("click me", "http://ruby-china.org")
end

给一个建议,把这个打到 Helper 里面去

controller 里面有个 view_context.link_to 方法

用 link_to 还不如直接写 html 代码呢

You need to Sign in before reply, if you don't have an account, please Sign up first.