<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: activerecord code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 12 May 2008 02:51:34 GMT</pubDate>
    <description>DZone Snippets: activerecord code</description>
    <item>
      <title>Perform a Rails find() and iterate over the resulting records in groups</title>
      <link>http://snippets.dzone.com/posts/show/5461</link>
      <description>&lt;code&gt;&lt;br /&gt;module ActiveRecord&lt;br /&gt;  class Base&lt;br /&gt;    # This method lets you iterate over the results of a .find, in groups.&lt;br /&gt;    # (Basically an interface to LIMIT.)&lt;br /&gt;    # Anything you can pass as options to .find, you can pass here. &lt;br /&gt;    # Example 1:&lt;br /&gt;    #   Order.each_by(100, :conditions =&gt; { :cc_processed_at =&gt; nil }) do |order|&lt;br /&gt;    #     # do stuff with order&lt;br /&gt;    #   end&lt;br /&gt;    # Example 2:&lt;br /&gt;    #   Person.each_by(50, :order =&gt; 'name') do |person, index|&lt;br /&gt;    #     # do stuff with person and index&lt;br /&gt;    #   end&lt;br /&gt;    # Pass :update =&gt; true in the options to print a message before each group is&lt;br /&gt;    # fetched from the db.&lt;br /&gt;    #&lt;br /&gt;    # Author: Elliot Winkler &lt;elliot.winkler@gmail.com&gt;&lt;br /&gt;    # Source: http://snippets.dzone.com/posts/show/5461&lt;br /&gt;    def self.each_by(group_size, options={}, &amp;blk)&lt;br /&gt;      update = options.delete(:update) || false&lt;br /&gt;      num_records = count(options.except(:from))&lt;br /&gt;      return 0 if num_records == 0&lt;br /&gt;      #raise "Number of records: #{num_records}"&lt;br /&gt;      also_pass_offset = (blk.arity == 2)&lt;br /&gt;      0.step(num_records, group_size) do |offset|&lt;br /&gt;        find_options = { :offset =&gt; offset, :limit =&gt; group_size }.merge(options)&lt;br /&gt;        if update&lt;br /&gt;          if num_records == 1&lt;br /&gt;            puts "&gt;&gt; Reading the only record."&lt;br /&gt;          else&lt;br /&gt;            start_offset = offset + 1&lt;br /&gt;            end_offset   = offset + group_size&lt;br /&gt;            end_offset   = num_records if num_records &lt; end_offset&lt;br /&gt;            puts "&gt;&gt; Reading records #{start_offset}-#{end_offset}."&lt;br /&gt;          end&lt;br /&gt;        end &lt;br /&gt;        find(:all, find_options).each do |record|&lt;br /&gt;          also_pass_offset ? blk.call(record, offset) : blk.call(record)&lt;br /&gt;        end&lt;br /&gt;      end&lt;br /&gt;      num_records&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 05 May 2008 15:35:43 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5461</guid>
      <author>mcmire ()</author>
    </item>
    <item>
      <title>annotate models with associations</title>
      <link>http://snippets.dzone.com/posts/show/5456</link>
      <description>slightly modified http://repo.pragprog.com/svn/Public/plugins/annotate_models/lib/annotate_models.rb to include short declarations for model associations.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require "config/environment"&lt;br /&gt;&lt;br /&gt;MODEL_DIR   = File.join(RAILS_ROOT, "app/models")&lt;br /&gt;FIXTURE_DIR = File.join(RAILS_ROOT, "test/fixtures")&lt;br /&gt;&lt;br /&gt;module AnnotateModels&lt;br /&gt;&lt;br /&gt;  PREFIX = "== Schema Information"&lt;br /&gt;  &lt;br /&gt;  # Simple quoting for the default column value&lt;br /&gt;  def self.quote(value)&lt;br /&gt;    case value&lt;br /&gt;      when NilClass                 then "NULL"&lt;br /&gt;      when TrueClass                then "TRUE"&lt;br /&gt;      when FalseClass               then "FALSE"&lt;br /&gt;      when Float, Fixnum, Bignum    then value.to_s&lt;br /&gt;      # BigDecimals need to be output in a non-normalized form and quoted.&lt;br /&gt;      when BigDecimal               then value.to_s('F')&lt;br /&gt;      else&lt;br /&gt;        value.inspect&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # Use the column information in an ActiveRecord class&lt;br /&gt;  # to create a comment block containing a line for&lt;br /&gt;  # each column. The line contains the column name,&lt;br /&gt;  # the type (and length), and any optional attributes&lt;br /&gt;  def self.get_schema_info(klass, header)&lt;br /&gt;    info = "# == Model #{klass}\n# #{header}\n#\n"&lt;br /&gt;    info &lt;&lt; "# Table name: #{klass.table_name}\n#\n"&lt;br /&gt;    &lt;br /&gt;    max_size = klass.column_names.collect{|name| name.size}.max + 1&lt;br /&gt;    klass.columns.each do |col|&lt;br /&gt;      attrs = []&lt;br /&gt;      attrs &lt;&lt; "default(#{quote(col.default)})" if col.default&lt;br /&gt;      attrs &lt;&lt; "not null" unless col.null&lt;br /&gt;      attrs &lt;&lt; "primary key" if col.name == klass.primary_key&lt;br /&gt;&lt;br /&gt;      col_type = col.type.to_s&lt;br /&gt;      if col_type == "decimal"&lt;br /&gt;        col_type &lt;&lt; "(#{col.precision}, #{col.scale})"&lt;br /&gt;      else&lt;br /&gt;        col_type &lt;&lt; "(#{col.limit})" if col.limit&lt;br /&gt;      end &lt;br /&gt;      info &lt;&lt; sprintf("#  %-#{max_size}.#{max_size}s:%-15.15s %s\n", col.name, col_type, attrs.join(", "))&lt;br /&gt;    end&lt;br /&gt;    assoc_list = klass.reflect_on_all_associations.sort {|x,y| d = x.class_name.to_s &lt;=&gt; y.class_name.to_s; c = d == 0 ? x.macro.to_s &lt;=&gt; y.macro.to_s : d; c == 0 ? x.name.to_s &lt;=&gt; y.name.to_s : c }&lt;br /&gt;    unless assoc_list.empty?&lt;br /&gt;      info &lt;&lt; "#\n# == Associations\n" &lt;br /&gt;      assoc_list.each do |assoc|&lt;br /&gt;        ao = assoc.options.dup&lt;br /&gt;        ao.delete(:class_name)&lt;br /&gt;        line = "# * " +sprintf("&lt;tt&gt;%-25s :%-25s (%s) %s&lt;/tt&gt;", assoc.macro, assoc.name, assoc.class_name, ao.empty? ? '' : ao.inspect)&lt;br /&gt;        info &lt;&lt; line &lt;&lt; "\n"&lt;br /&gt;      end &lt;br /&gt;    end&lt;br /&gt;    info &lt;&lt; "#\n\n"&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # Add a schema block to a file. If the file already contains&lt;br /&gt;  # a schema info block (a comment starting&lt;br /&gt;  # with "Schema as of ..."), remove it first.&lt;br /&gt;&lt;br /&gt;  def self.annotate_one_file(file_name, info_block)&lt;br /&gt;    if File.exist?(file_name)&lt;br /&gt;      content = File.read(file_name)&lt;br /&gt;&lt;br /&gt;      # Remove old schema info&lt;br /&gt;      content.sub!(/^# #{PREFIX}.*?\n(#.*\n)*\n/, '')&lt;br /&gt;&lt;br /&gt;      # Write it back&lt;br /&gt;      File.open(file_name, "w") { |f| f.puts info_block + content }&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  # Given the name of an ActiveRecord class, create a schema&lt;br /&gt;  # info block (basically a comment containing information&lt;br /&gt;  # on the columns and their types) and put it at the front&lt;br /&gt;  # of the model and fixture source files.&lt;br /&gt;&lt;br /&gt;  def self.annotate(klass, header)&lt;br /&gt;    info = get_schema_info(klass, header)&lt;br /&gt;    &lt;br /&gt;    model_file_name = File.join(MODEL_DIR, klass.name.underscore + ".rb")&lt;br /&gt;    annotate_one_file(model_file_name, info)&lt;br /&gt;&lt;br /&gt;    fixture_file_name = File.join(FIXTURE_DIR, klass.table_name + ".yml")&lt;br /&gt;    annotate_one_file(fixture_file_name, info)&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # Return a list of the model files to annotate. If we have &lt;br /&gt;  # command line arguments, they're assumed to be either&lt;br /&gt;  # the underscore or CamelCase versions of model names.&lt;br /&gt;  # Otherwise we take all the model files in the &lt;br /&gt;  # app/models directory.&lt;br /&gt;  def self.get_model_names&lt;br /&gt;    models = ARGV.dup&lt;br /&gt;    models.shift&lt;br /&gt;    &lt;br /&gt;    if models.empty?&lt;br /&gt;      Dir.chdir(MODEL_DIR) do &lt;br /&gt;        models = Dir["**/*.rb"]&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;    models&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # We're passed a name of things that might be &lt;br /&gt;  # ActiveRecord models. If we can find the class, and&lt;br /&gt;  # if its a subclass of ActiveRecord::Base,&lt;br /&gt;  # then pas it to the associated block&lt;br /&gt;&lt;br /&gt;  def self.do_annotations&lt;br /&gt;    header = PREFIX.dup&lt;br /&gt;    version = ActiveRecord::Migrator.current_version rescue 0&lt;br /&gt;    if version &gt; 0&lt;br /&gt;      header &lt;&lt; "\n# Schema version: #{version}"&lt;br /&gt;    end&lt;br /&gt;    &lt;br /&gt;    self.get_model_names.each do |m|&lt;br /&gt;      class_name = m.sub(/\.rb$/,'').camelize&lt;br /&gt;      begin&lt;br /&gt;        klass = class_name.split('::').inject(Object){ |klass,part| klass.const_get(part) }&lt;br /&gt;        if klass &lt; ActiveRecord::Base &amp;&amp; !klass.abstract_class?&lt;br /&gt;          puts "Annotating #{class_name}"&lt;br /&gt;          self.annotate(klass, header)&lt;br /&gt;        else&lt;br /&gt;          puts "Skipping #{class_name}"&lt;br /&gt;        end&lt;br /&gt;      rescue Exception =&gt; e&lt;br /&gt;        puts "Unable to annotate #{class_name}: #{e.message}"&lt;br /&gt;      end&lt;br /&gt;      &lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 03 May 2008 11:05:17 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5456</guid>
      <author>dseverin ()</author>
    </item>
    <item>
      <title>ActiveRecord Class Example</title>
      <link>http://snippets.dzone.com/posts/show/5379</link>
      <description>// Trying out the system, here is just a simple ActiveRecord class&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Task &lt; ActiveRecord::Base &lt;br /&gt;  belongs_to :user&lt;br /&gt;  belongs_to :location&lt;br /&gt;  belongs_to :project&lt;br /&gt;end .&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 17 Apr 2008 14:30:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5379</guid>
      <author>curtis (Curtis Hermann)</author>
    </item>
    <item>
      <title>Finding recent data in database</title>
      <link>http://snippets.dzone.com/posts/show/5341</link>
      <description>This shows how to find recent data from last hour, day, week, month, whatever&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Post &lt; ActiveRecord::Base&lt;br /&gt;  def self.find_latest(time = nil)&lt;br /&gt;    r = %w( hour day week month year )&lt;br /&gt;    if r.include?(time)&lt;br /&gt;      self.find :all, :conditions =&gt; ['created_at &gt; ?', 1.send(time).ago]&lt;br /&gt;    else&lt;br /&gt;      self.find :all&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;Post.find_latest('day')&lt;br /&gt;Post.find_latest('week')&lt;br /&gt;Post.find_latest('year')&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 09 Apr 2008 20:34:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5341</guid>
      <author>ronin (Micha&#322; M)</author>
    </item>
    <item>
      <title>Custom Rails Callback</title>
      <link>http://snippets.dzone.com/posts/show/5226</link>
      <description>// This shows you how to extend active record to allow a custom callback.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#ever needed to add your own callback into the active record callback chain?&lt;br /&gt;#here's how...&lt;br /&gt;module ActiveRecord&lt;br /&gt;  &lt;br /&gt;  #to keep things clean we'll define our own module&lt;br /&gt;  module SweetCustomCallbacks&lt;br /&gt;    &lt;br /&gt;    #this is the ruby method that is called when you call include on a module&lt;br /&gt;    #the method passed, base in our case, is the class your including yourself in&lt;br /&gt;    def self.included(base)&lt;br /&gt;      &lt;br /&gt;      #this clas_eval method takes a block that will be added to base, which is ActiveRecord::Base&lt;br /&gt;      #basically this is like writing code directly into the class ActiveRecord::Base&lt;br /&gt;      base.class_eval do&lt;br /&gt;        &lt;br /&gt;        #alias_method_chain is very cool&lt;br /&gt;        #it allows us override a method without removing the original and without the original knowing its been changed&lt;br /&gt;        #here's how it works:&lt;br /&gt;        # 1st argument is the name of the method you're overriding&lt;br /&gt;        # 2nd argument is feature you want to add&lt;br /&gt;        # so if create_or_update is called it will actually call create_or_update_with_sweet_custom_callbacks&lt;br /&gt;        # the original is still avaliable at create_or_update_without_custom_callbacks&lt;br /&gt;        &lt;br /&gt;        alias_method_chain :create_or_update, :sweet_custom_callbacks&lt;br /&gt;        #the method create_or_update is an internals method to ActiveRecord that is called whenever you call .save or .update&lt;br /&gt;        &lt;br /&gt;        #this is the class method that allows the cool syntax:&lt;br /&gt;        # class Article &lt; ActiveRecord::Base&lt;br /&gt;        # before_before_save :add_authors_name&lt;br /&gt;        #private&lt;br /&gt;        #def add_authors_name&lt;br /&gt;        #.....&lt;br /&gt;        def self.before_before_save(*callbacks, &amp;block)&lt;br /&gt;          callbacks &lt;&lt; block if block_given? #add the block to the array of callback functions if a block was passed&lt;br /&gt;          write_inheritable_array(:before_before_save,callbacks) &lt;br /&gt;        end&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;    &lt;br /&gt;    #the instance method, although not recomended is avaliable for overriding&lt;br /&gt;    #also if you wanted to have a callback that always did something say add the users's id to the object &lt;br /&gt;    #you could always code that in here and remove the class above&lt;br /&gt;    def before_before_save() end&lt;br /&gt;&lt;br /&gt;    #ok this is the method that is now called instead of create_or_update&lt;br /&gt;    #it calls a method callback on &lt;br /&gt;    def create_or_update_with_sweet_custom_callbacks&lt;br /&gt;      return false if callback(:before_before_save) == false  #this method does all the real work and calls the callback function in callbacks.rb that gets the methods and runs them &lt;br /&gt;      create_or_update_without_sweet_custom_callbacks&lt;br /&gt;    end&lt;br /&gt;    &lt;br /&gt;   end&lt;br /&gt; &lt;br /&gt;   class Base    &lt;br /&gt;     include SweetCustomCallbacks #include our module in ActiveRecord::Base&lt;br /&gt;   end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 13 Mar 2008 16:28:28 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5226</guid>
      <author>onkis (Mike Ball)</author>
    </item>
    <item>
      <title>Rails MySQL/SQLite convenience methods</title>
      <link>http://snippets.dzone.com/posts/show/5148</link>
      <description>Usage:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  Person.find :all, :conditions =&gt; ["#{sql_year 'birthday'} &gt;= ?", year]&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SQLITE = true # or false&lt;br /&gt;&lt;br /&gt;def sql_concat(*args)&lt;br /&gt;  SQLITE ? args.join(' || ') : "CONCAT(#{args.join(', ')})"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def sql_lcase(expr)&lt;br /&gt;  SQLITE ? "LOWER(#{expr})" : "LCASE(#{expr})"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def sql_year(expr)&lt;br /&gt;  SQLITE ? "CAST(STRFTIME('%y', #{expr}) as 'INTEGER')" : "YEAR(#{expr})"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def sql_month(expr)&lt;br /&gt;  SQLITE ? "CAST(STRFTIME('%m', #{expr}) as 'INTEGER')" : "MONTH(#{expr})"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def sql_day(expr)&lt;br /&gt;  SQLITE ? "CAST(STRFTIME('%d', #{expr}) as 'INTEGER')" : "DAY(#{expr})"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def sql_now&lt;br /&gt;  SQLITE ? "CURRENT_TIMESTAMP" : "NOW()"&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 18 Feb 2008 02:57:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5148</guid>
      <author>timmorgan (Tim Morgan)</author>
    </item>
    <item>
      <title>Rails Array#add_condition Method</title>
      <link>http://snippets.dzone.com/posts/show/5147</link>
      <description>Lets you add a condition to a set of ActiveRecord conditions easily like this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  conditions = ['active = ? and type = ?', true, 2]&lt;br /&gt;  conditions.add_condition ['person_id = ?', 345]&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Array&lt;br /&gt;  def add_condition(condition, conjunction='and')&lt;br /&gt;    if condition.is_a? Array&lt;br /&gt;      if self.empty?&lt;br /&gt;        (self &lt;&lt; condition).flatten!&lt;br /&gt;      else&lt;br /&gt;        self[0] += " #{conjunction} " + condition.shift&lt;br /&gt;        (self &lt;&lt; condition).flatten!&lt;br /&gt;      end&lt;br /&gt;    elsif condition.is_a? String&lt;br /&gt;      self[0] += " #{conjunction} " + condition&lt;br /&gt;    else&lt;br /&gt;      raise "don't know how to handle this condition type"&lt;br /&gt;    end&lt;br /&gt;    self&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 18 Feb 2008 02:54:44 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5147</guid>
      <author>timmorgan (Tim Morgan)</author>
    </item>
    <item>
      <title>Marshalize (Cache) ActiveRecord Query Results</title>
      <link>http://snippets.dzone.com/posts/show/5058</link>
      <description>A quick way to cache results in a file and read from the file on subsequent requests instead of the database. Makes the initial query a bit slower, but later queries *much* faster.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class MyCachedModel &lt; ActiveRecord::Base&lt;br /&gt;  class &lt;&lt; self&lt;br /&gt;    alias_method :rails_original_find_by_sql, :find_by_sql&lt;br /&gt;    def find_by_sql(sql)&lt;br /&gt;      cache_filename = Base64.encode64(sql)&lt;br /&gt;      if File.exists? cache_filename&lt;br /&gt;        Marshal.load(File.open(cache_filename))&lt;br /&gt;      else&lt;br /&gt;        Marshal.dump(records = rails_original_find_by_sql(sql), File.open(cache_filename, 'w'))&lt;br /&gt;        return records&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 31 Jan 2008 01:37:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5058</guid>
      <author>timmorgan (Tim Morgan)</author>
    </item>
    <item>
      <title>Rails validation for Phone</title>
      <link>http://snippets.dzone.com/posts/show/5057</link>
      <description>&lt;code&gt;&lt;br /&gt;  validates_length_of :phone, :is =&gt; 10, :message =&gt; 'must be 10 digits, excluding special characters such as spaces and dashes. No extension or country code allowed.', :if =&gt; Proc.new{|o| !o.phone.blank?}&lt;br /&gt;  validates_length_of :fax, :is =&gt; 10, :message =&gt; 'must be 10 digits, excluding special characters such as spaces and dashes. No extension or country code allowed.', :if =&gt; Proc.new{|o| !o.fax.blank?}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 31 Jan 2008 00:38:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5057</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
    <item>
      <title>Crack open Firefox's new Places sqlite database with ActiveRecord</title>
      <link>http://snippets.dzone.com/posts/show/4901</link>
      <description>&lt;code&gt;&lt;br /&gt;require "rubygems"&lt;br /&gt;require "active_record"&lt;br /&gt;require "active_support"&lt;br /&gt;&lt;br /&gt;ActiveRecord::Base.establish_connection(&lt;br /&gt;	:adapter =&gt; "sqlite3",&lt;br /&gt;	:database =&gt; "places.sqlite"&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;class MozHistoryvisit &lt; ActiveRecord::Base&lt;br /&gt;	belongs_to :place, :class_name =&gt; "MozPlaces", :foreign_key =&gt; "place_id"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;class MozPlaces &lt; ActiveRecord::Base&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;p Time.now.yesterday&lt;br /&gt;from = Time.now.yesterday.to_i * 1000000&lt;br /&gt;&lt;br /&gt;MozHistoryvisit.find(:all, :conditions =&gt; ["visit_date &gt; ?", from]).each do |h|&lt;br /&gt;	place = h.place&lt;br /&gt;	puts place.title&lt;br /&gt;	puts place.url&lt;br /&gt;	puts place.visit_count&lt;br /&gt;	puts&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 17 Dec 2007 23:09:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4901</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
  </channel>
</rss>
