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

lb563 · 2012年03月20日 · 最后由 nouse 回复于 2012年03月20日 · 2189 次阅读

现在想在 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 代码呢

需要 登录 后方可回复, 如果你还没有账号请 注册新账号