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. Anyone mind telling me what''s wrong ? TIA Stuart -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060612/12644f9b/attachment.html
>>>>> "Dark" == Dark Ambient <sambient@gmail.com> writes:> Anyone mind telling me what''s wrong ?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 Dybedahl <calle@cyberpomo.com> http://www.livejournal.com/users/cdybedahl/ "Let me answer that question with a headbutt." -- Buffy, Buffy the Vampire Slayer
Good question, with the only answer right now being "I just assume" ;) So, I''ll try doing something like this: State.create(:state => ''New York'', Stuart On 6/12/06, Calle Dybedahl <rails@cyberpomo.com> wrote:> > >>>>> "Dark" == Dark Ambient <sambient@gmail.com> writes: > > > Anyone mind telling me what''s wrong ? > > 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 Dybedahl <calle@cyberpomo.com> > http://www.livejournal.com/users/cdybedahl/ > "Let me answer that question with a headbutt." > -- Buffy, Buffy the Vampire Slayer > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060612/06e86fea/attachment.html
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 On 6/12/06, Dark Ambient <sambient@gmail.com> wrote:> > Good question, with the only answer right now being "I just assume" ;) > So, I''ll try doing something like this: > > State.create(:state => ''New York'', > > Stuart > > > On 6/12/06, Calle Dybedahl <rails@cyberpomo.com> wrote: > > > > >>>>> "Dark" == Dark Ambient <sambient@gmail.com> writes: > > > > > Anyone mind telling me what''s wrong ? > > > > 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 Dybedahl <calle@cyberpomo.com> > > http://www.livejournal.com/users/cdybedahl/ > > "Let me answer that question with a headbutt." > > -- Buffy, Buffy the Vampire Slayer > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060612/12c43fc9/attachment-0001.html