KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to migrate my application from Rails 3.0.7 to Rails 3.1.3. I have client model class Client::Client < ActiveRecord::Base has_one :contact_address, :class_name => "Address", :foreign_key => :client_id, :conditions => ["kind = ? and state = ?", 2, 1] end In controller's edit method I execute this code: def edit @client = params[:type].classify.constantize.find params[:id] @client.contact_address = Address.new(:kind => 2) if @client.contact_address.blank? end In second line of this code I'm getting error: Failed to save the new associated contact_address. So it seems that assignment to @client.contact_address somehow triggered save method on contact_address object... I do not want that... Is this some new Rails 3.1.x behavior? I want associated objects to save only when I call .save! on parent model - this is too much magic for me. Can I disable this behavior somewhere?
Tags (comma-separated)
Save Edits
Cancel