Forum: Ruby on Rails Insert using Rake Task

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Rake N. (Guest)
on 2009-03-05 09:11

Anyone can help me, I run my source code using rake task. It seems no
error was trace, but when I look the table it doesn't insert.I select
the data here MysqlDB.Tablename and update/insert here

# Start Here
# rake mysqldata_select:sqldata_update
def clean_html(html)
  new_html = strip_tags(html) # remove html tags
  new_html = decode_entities(new_html) # remove html encoded items
  new_html = new_html.strip # remove any whitespace from the edge of

namespace :mysqldata_select do

  LOCATIONS = {1 => 6, 2 => 5, 3 => 5}

  task :sqldata_update => :environment do
    include ActionView::Helpers::SanitizeHelper

    MysqlData::TableName.all(:conditions => {:field_id => [1,2,3]},
:order => :field_primary).each{ |j|
      r =
      # place
      r.field = j.field_primary
      r.location_id = LOCATIONS[j.field_id]
      # save the item to get an ID
      # find any translations
      attributes = {}
      %w{tc sc jp kr pt}.each{ |language|
        attributes[language] = {}
        field = j.field_primary(language, true)
        attributes[language]['field'] = field unless field.nil?
      # insert the translations
      puts r.field
      # break
# End Here

Thanks in Advance
This topic is locked and can not be replied to.