之前,我想渲染activescaffold索引视图之前调用activescaffold @records在操纵过滤
@records.collect{|r| r.set_some_virtual_attribute(@context)}
,但如果我这样做:
controller FooController < ApplicationController
before_filter :change_things, :only => :index
active_scaffold :foos
protected
def change_things
@records.collect{|r| r.set_some_virtual_attribute(@context)}
end
end
我得到:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.collect
当调用索引视图。如果我在ActiveScaffold调用之后放置过滤器,也会发生同样的情况。我可以采取一些不同的方法,但底线是我需要根据控制器的某些上下文在@records中设置每个对象的虚拟属性以显示在决赛表中
thx
-C