我有屬於某個客戶經理的帳戶型號:Rails應用程序不能識別質量分配belongs_to的關聯生產
class Account < ActiveRecord::Base
belongs_to :account_manager, :class_name => 'User'
validates_presence_of :account_manager
end
我的控制器看起來是這樣的:
def create
@account = Account.new(params[:account])
...
的請求看起來像這個:
Started POST "/accounts" for 74.61.248.151 at Sun Sep 26 16:12:26 +0000 2010
Processing by AccountsController#create as HTML
Parameters: {"commit"=>"Create Account", "account"=>{"name"=>"", "account_manager_id"=>["171"]}, "authenticity_token"=>"T4ERO0iMtseI952LP/9gf5EcYrRCE/3pQFdSgqi3hNg=", "utf8"=>"\342\234\223"}
出於某種原因,在提交這個請求後,表單說:客戶經理是空白的。但是這隻發生在生產上,而不是在本地開發。任何人見過這個?唯一的區別是我在生產中使用REE,但我不認爲這會是一個問題,因爲這是Rails的功能。 Rails的版本是在本地和生產線相同 - 3.0.0
in rails 2.3你必須做'Account.accepts_nested_attributes_for:account_manager' – glebm 2010-09-26 16:26:15
我試過了,它沒有改變任何東西 – Tony 2010-09-26 17:11:14