新手问题 Rails 3 中 model 层怎么获取 session 里面的值

yuan_yp · July 04, 2013 · Last by yuan_yp replied at July 04, 2013 · 2682 hits

如标题描述

传过去

class C < ..
  def index
    Post.find(params[:id]).f session
    ...
  end
end

class M < ..
  def f session
    ...
  end
end

#1 楼 @night_song 大神,写明白点,我看不太懂,你在哪里取到 session 里面的值了。f.session 只是一个方法

#2 楼 @yuan_yp

假设你在 model 里有个方法 f 要访问 session 从 controller 里把 session 取出来,然后传给 f 就可以了

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