The standard idiom here is to have grow take a block, thus:

def self.grow (model_name, filename, headers = true)
    Kernel.const_get(model).delete_all
    table = FasterCSV.table(filename, {
       :headers => headers,
       :header_converters => :symbol,
       :col_sep => "\t" # need the double quotes
       })
    table.each do |row|
      yield(row)
    end
end

and then call with:

Plant.grow(...params here...) do |row|
  Business.create(
    :address         => row[:vendoraddress],
    :city            => row[:vendorcity],
    :email_general   => row[:vendoremail],
    :fax             => row[:faxnumber],
    :name            => row[:vendorname],
    :old_vendorid    => row[:vendorid],
    :phone           => row[:vendorphone],
    :sales_tax_rate  => row[:vendorsalestax],
    :zip_code        => row[:vendorzipcode]
  )
end

--Matt Jones

On Sep 16, 3:31 pm, Bill Devaul <[email protected]>
wrote:
> Philip Hallstrom wrote:
> > Oh, could be... there's probably another method that will give you
> > back key/value pairs for FasterCSV::Row.
>
> > -philip
>
> It looks like each_pair and each are identical methods.  I can
> instance.each {|k,v| k = v } no problem.
>
> Any other ideas?
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to