output to mysql db

F

furfey

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
 
C

Chris Lowis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,222
Messages
2,571,142
Members
47,756
Latest member
JulienneY0

Latest Threads

Top