This project is archived and is in readonly mode.

#5334 ✓invalid
Neeraj Singh

autosave => false should be same as not declaring autosave

Reported by Neeraj Singh | August 8th, 2010 @ 05:06 AM | in 3.x

  has_many :brakes, :autosave => false

Above statement is not same as

 has_many :brakes
class Car < ActiveRecord::Base
  has_many :brakes, :autosave => false

  def self.lab
    Car.delete_all
    Brake.delete_all
    c = Car.create
    c.brakes.build(:name => nil)
    c.save
    c.reload
    puts c.brakes.size #=> 0
  end
end

class Car < ActiveRecord::Base
  has_many :brakes#, :autosave => false (notice the # earlier in the string)

  def self.lab
    Car.delete_all
    Brake.delete_all
    c = Car.create
    c.brakes.build(:name => nil)
    c.save
    c.reload
    puts c.brakes.size #=> 1
  end
end

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages