P
Pete Moran
Not sure if this should be on the rails or ruby forum, so my apologies
if I got it wrong!
So I have created a new rails application, however I want to load data
from a file into a database table which has a Model associated with it.
My ruby script opens the file, and I want to use the Model to insert the
data into the database. The script is pretty simple, but it doesn't
seem to like loading the model and I created a new folder called
helper_scripts in the root of the rails application.
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../app/models/country.rb'
data_file = "/tmp/countries"
File.open("/tmp/countries").each { |line|
data = line.split("\t")
Country.new
}
However it fails when trying to load the Model (let alone use it), I
know this is a total newbie question just need to know how I can use my
models outside the rails application? or am I doing something
fundamentally wrong?
Many Thanks
Peter
if I got it wrong!
So I have created a new rails application, however I want to load data
from a file into a database table which has a Model associated with it.
My ruby script opens the file, and I want to use the Model to insert the
data into the database. The script is pretty simple, but it doesn't
seem to like loading the model and I created a new folder called
helper_scripts in the root of the rails application.
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../app/models/country.rb'
data_file = "/tmp/countries"
File.open("/tmp/countries").each { |line|
data = line.split("\t")
Country.new
}
However it fails when trying to load the Model (let alone use it), I
know this is a total newbie question just need to know how I can use my
models outside the rails application? or am I doing something
fundamentally wrong?
Many Thanks
Peter