我有模式:FactoryGirl模型的id =>零
class CreateStores < ActiveRecord::Migration
def change
create_table :stores do |t|
t.integer :admin_id
t.string :name
t.string :subdomain
t.string :linked_domain
t.timestamps
end
end
end
和測試:
require 'test_helper'
class Api::Be::UsersControllerTest < ActionController::TestCase
setup do
@admin = FactoryGirl.create :admin
@store = FactoryGirl.create :store
@store.ug_default = UgDefault.new
@store.save
Rails::logger.debug "HERE: #{@store.id}"
@customer = FactoryGirl.create :customer
@customer.userable_id = @store.id
@customer.save
end
在日誌中我看到@store.id
等於爲零。有什麼問題?
你的模型怎麼樣? –