之前,我想渲染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