Jam*_*sen 16
更常见的方法是将类变量包装在辅助方法中:
# in /app/controllers/foo_controller.rb:
class FooController < ApplicationController
@@bar = 'baz'
def my_action
end
helper_method :bar
def bar
@@bar
end
end
# in /app/views/foo/my_action.html.erb:
It might be a class variable, or it might not, but bar is "<%= bar -%>."
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5325 次 |
最近记录: |