我正在尝试将我的应用程序从Rails 3.0.7迁移到Rails 3.1.3.我有客户端模型
class Client::Client < ActiveRecord::Base has_one :contact_address,:class_name => "Address",:foreign_key => :client_id,:conditions => ["kind = ? and state = ?",2,1] end
def edit @client = params[:type].classify.constantize.find params[:id] @client.contact_address = Address.new(:kind => 2) if @client.contact_address.blank? end
Failed to save the new associated contact_address.
所以似乎@ client.contact_address的赋值以某种方式在contact_address对象上触发了save方法……我不希望这样……这是一些新的Rails 3.1.x行为吗?我希望只有在我调用.save时才能保存相关对象!在父模型上 – 这对我来说太神奇了.我可以在某处禁用此行为吗?