新手问题 如何让一个 method 在多个 controller 里可用

Unknow user · August 17, 2012 · Last by evan replied at August 18, 2012 · 2172 hits

在 helper 里面,只能在和此 helper 对应的 controller 和 view 当中可用

写在 application 中,加上 helper_method,还有什么好说的?

或者写个 Moudel,然后 controller include 进来就 ok 了

Unknow user #3 August 17, 2012

#1 楼 @zgm #2 楼 @robertyu 你们二位的方法,发贴前已经试过了,不工作,明天再搞啦

不工作我把电脑吃了。

支持 module,可以好好测试

你这个不是 helper 能不能用的问题吧... session[:user_id] 你想想 session 里没有这个 user_id 的时候 current_user 是什么...

可以写在任何 helper 里面,调用的时候 include XxxHelper

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