Witam,
Moze odrazu podam przyklad, bedzie szybciej.
file: migrate/20090309104328_create_users.rb
[code]class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.string :hashed_password
t.string :salt
t.timestamps
end
end
def self.down
drop_table :users
end
end[/code]
file: schema.rb
ActiveRecord::Schema.define(:version => 20090309104328) do
create_table "users", :id => false, :force => true do |t|
t.integer "id", :default => 0, :null => false
t.string "name"
t.string "hashed_password"
t.string "salt"
t.timestamp "created_at"
t.timestamp "updated_at"
end
end
Skad sie bierze “:id => false” w schema.rb ??
Zgodnie z dokumentacją dla “create_table”:
Whether to automatically add a primary key column. Defaults to true. Join tables for has_and_belongs_to_many should set :id => false.[/quote]
Pozdrawiam