method then it works but when I put this in my migration then this don't
work. Why so
============================================================
In My Controller's index method. It works.
require 'csv'
CSV.foreach("#{Rails.root}/db/adwords_location_data/languages.csv")
do |row|
obj_language = Language.new
obj_language.name = row[1]
obj_language.adwords_id = row[0]
obj_language.save
end
===========================================================
But When I write this in my migration this doesn't work. No error come
but data didn't inserted in the tables. Below is the migration code.
require "csv"
class LoadLanguageData < ActiveRecord::Migration
def self.up
CSV.foreach("#{Rails.root}/db/adwords_location_data/languages.csv") do
row|
obj_language = Language.newobj_language.name = row[1]
obj_language.adwords_id = row[0]
obj_language.save
end
end
def self.down
Language.destroy_all
end
end
--
Posted via http://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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.