Read table row-by-row in ruby

Posted by Brad Wed, 12 Mar 2008 01:00:00 GMT

I needed to export some data from a huge data table. Iterating through MyModel.find took too long and too much ram, so I went straight to the db instead.

Example code was tough to find, so here's an example:
sql = "select * from #{ MyModel.table_name }"
MyModel.connection.execute(sql) do |handle|
  handle.fetch do |row|
    # row is an array of values
    ... export row ...
  end
end

Using Javascript Code for RJS Instead of IDs 3

Posted by Brad Mon, 05 Nov 2007 01:31:00 GMT

Some info on how to make RJS output code like:

new Insertion.Bottom($$('p.welcome b').first(), "Some item"
http://sentia.com.au/2008/03/using-javascript-code-for-rjs.html