Forum: Ruby output to mysql db

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7a0237a8c808db7572e49984372d5c6b?d=identicon&s=25 furfey@gmail.com (Guest)
on 2007-01-17 19:15
(Received via mailing list)
Hello,

Very new to Ruby and I'm curious if this is possible....

I have the following code which is returning a chunk of html that I
want.

Right now, all it does is print to the screen.  Is it possible to have
the outputted chunk of html placed in a mysql db record?  If so, can
anyone recommend some starting resources or examples.

Thanks!


#!/usr/bin/env ruby

require 'hpricot'
require 'open-uri'

doc = Hpricot(open("some_url"))

doc.search('dir').each do | element |
  puts "#{element.inner_html}"
end
A8486651a974d7d9ecc35d25de96c7ee?d=identicon&s=25 Chris Lowis (chrislo)
on 2007-01-17 19:36
furfey@gmail.com wrote:
> Hello,
>
> Very new to Ruby and I'm curious if this is possible....
>
> I have the following code which is returning a chunk of html that I
> want.
>
> Right now, all it does is print to the screen.  Is it possible to have
> the outputted chunk of html placed in a mysql db record?  If so, can
> anyone recommend some starting resources or examples.

Try ActiveRecord it's part of Ruby on Rails :
http://rubyonrails.org/api/classes/ActiveRecord/Base.html

There's some good examples in the Ruby Cookbook:
http://www.crummy.com/writing/RubyCookbook/

Chris
This topic is locked and can not be replied to.