Inserting records on a migration question


G

Gene Jones

Hi,

I am trying to create a user_types table and insert two rows into it.
See code below:

class CreateUserAccountTypes < ActiveRecord::Migration
def self.up
create_table :user_types do |g|
g.column :name, :string, :default => nil
g.column :has_admin_access, :boolean, :default => false
end

UserType.create :name=> 'Member', :has_admin_access => false
UserType.create :name=> 'Admin Member', :has_admin_access => true
end

def self.down
drop_table :user_types
end
end

However I keep getting this error after running rake db:migrate
(in C:/Ruby/InstantRails/rails_apps/Eivom)
== CreateUserAccountTypes: migrating
======================================
-- create_table:)user_types)
-> 0.0220s
rake aborted!
uninitialized constant CreateUserAccountTypes::UserType

(See full trace by running task with --trace)

It works fine if I remove the "UserType.create " line. Any ideas?

Thanks
Gene
 
Ad

Advertisements

Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top