I’m digging around and googling but can’t seem to find what I think is a
simple thing. All I’m trying to do is insert data in a migration into a
table, using regular SQL statements.
LIke this:
class AddStateData < ActiveRecord::Migration
def self.up
INSERT INTO states values (’’,‘Alaska’);
INSERT INTO states values (’’, ‘Arkansas’);
INSERT INTO states VALUES (’’, ‘Arizona’);
INSERT INTO states VALUES (’’, ‘California’);
INSERT INTO states VALUES (’’, ‘Colorado’);
INSERT INTO states VALUES (’’, ‘Connecticut’);
INSERT INTO states VALUES (’’, ‘District of Columbia’);
INSERT INTO states VALUES (’’, ‘Delware’);
INSERT INTO states VALUES (’’, ‘Florida’);
INSERT INTO states VALUES (’’, ‘Georgia’);
INSERT INTO states VALUES (’’, ‘Hawaii’);
Pretty simple i think, but in RadRails it shows multiple syntax errors.
You’re putting wodges of one programming language into code written in
another one. What on Earth made you think you could just start putting
SQL into your Ruby program?
Calle D. <[email protected]>
http://www.livejournal.com/users/cdybedahl/
"Let me answer that question with a headbutt."
-- Buffy, Buffy the Vampire Slayer
Interestingly enough once I got the migration code correct I found out
that
there needs to be a model in place . I had made the error of creating
the
create table migration code first, then the add data for the table. Once
I
created the model though I see it wanted to make the migration for
creating
the table but didn’t override the existing file. Once the model was in
place I could add the data to the table.
Sorry, I’m rambling.
Stuart
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.