I have the following class method in a Rails model, in which I retrieve
some objects from the DB…
@bubbles = Bubble.find(:all, :limit => 30) # What is the limit?
open( “public/xml_data/main_data_feed.xml”, “w” ) { | l | l.write
ERB.new( IO.read( File.join( RAILS_ROOT,
“app/views/rssfeed/bubbles.rhtml” ) ) ).result }
When I attempt to run this with runner I get the following error…
./script/runner XmlInterface.generate
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/runner.rb:47:
(erb):14: You have a nil object when you didn’t expect it!
(NoMethodError)
You might have expected an instance of Array.
The error occurred while evaluating nil.first
It seems as though the @bubble object is not being passed to the render,
event though it definitely has data in it.
I have the following class method in a Rails model,
in which I retrieve some objects from the DB…
It’s often something simple like…
@bubbles = Bubble.find
the @bubble object
OTOH, if that’s just a type (bubbles vs. bubble) then I’d say we need
more
info. In general, views get fed by a controller method rather than by
methods in the model. Not sure what would happen if you didn’t have a
controller method named bubbles. Have you tried putting the method
that’s
currently in your Bubble model in the controlleer?
Best regards,
Bill
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.