Hi peoples. 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. Anyone any idea what is going wrong? Thanks in advance. Dougal [ http://douglasfshearer.com ] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Douglas, Douglas Shearer wrote:> 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 objectOTOH, 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You need to pass in the binding of the current method. @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(binding) } On Mar 9, 1:50 am, Douglas Shearer <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi peoples. > > 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. > > Anyone any idea what is going wrong? > > Thanks in advance. > > Dougal [http://douglasfshearer.com] > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---