views:

261

answers:

2

Hi All,

I would like to call

@records.collect{|r| r.set_some_virtual_attribute(@context)}

before rendering an activescaffold index view, but if I do this :

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

I get :

 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

when calling the index view. The same thing happens if I put the filter after the ActiveScaffold call. I would be fine with taking a different approach of some sort, but the bottom line is that I need to set a virtual attribute of each object in @records based on some context from the controller for display in the final table

thx

-C

A: 

I haven't testing this but i think it should be @foos.collect rather than @records.collect

so1o
A: 

you don't really need to access this collection in the controller. what i wanted to do can be solved with the appropriate helper methods being defined.

Chris Drappier