From: Paul Smith Date: 2009-09-23T00:54:23+09:00 Subject: Re: decompose ActiveRecord script into methods On Tue, Sep 22, 2009 at 4:45 PM, Thufir wrote: > If I commend out the def and end lines for the "all" method, the script > runs fine.  However, the goal is to decompose the script into several > methods, which fails with: > > thufir@ARRAKIS:~/projects/aggregator$ > thufir@ARRAKIS:~/projects/aggregator$ ruby rss2mysql.rb > rss2mysql.rb:19: class definition in method body > thufir@ARRAKIS:~/projects/aggregator$ > > The error message tells you exactly what is wrong: > class Items <  ActiveRecord::Base > end You can't have a class declaration like this inside a method body. Instead of making a single method around the whole script, make at least 2 methods, one which covers the code before the class declaration, then one which covers the code after it. Or move the class definition to the top of the file, before def all. > thanks, > > Thufir > > > -- Paul Smith http://www.nomadicfun.co.uk paul@pollyandpaul.co.uk