Displaying 2 results from an estimated 2 matches for "001_create_users".
2006 Jun 19
1
AWDwR2: Loading data in migrations
...o
do this. This allows you a good way to create sample data that you can use
during development, testing or demoing of an application. My question is
how do you keep it separated from the real data? For example, say you have
a User and Account model. You might end up with migrations like this:
001_create_users.rb
002_load_sample_users.rb
003_create_accounts.rb
004_load_sample_accounts.rb
When you go to production, you don''t want the sample users or accounts
loaded, but when you run rake db:migrate, they will get loaded. Is there a
way to handle this? It almost seems like loading sample data s...
2007 Jun 02
2
Unit tests breaks with sqlite
...ne is
* rails my_app
* edited database.yml to use sqlite3 adapter, db/my_app_development
and db/my_app_test
* ruby script\generate model user
* edited model
class User < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name
end
* edited db/migrate/001_create_users.rb migration:
def self.up
create_table :users do |t|
t.column :name, :string, :null => false
end
User.create(:name => ''administrator'')
end
* and:
def self.down
drop_table :users
end
* rake db:migrate
* rake db:test...