It may be something completely simple, but I cannot let my life work. For some reason: autosave does not actually autosave the base models.
Here is my diagram:
create_table :albums do |t| t.string :title t.text :review t.timestamps end create_table :songs do |t| t.integer :album_id t.string :name t.integer :length end create_table :cover_arts do |t| t.integer :album_id t.integer :artist end
Here are my models:
class Album < ActiveRecord::Base has_many :songs, :autosave => true has_one :cover_art, :autosave => true end class CoverArt < ActiveRecord::Base belongs_to :album end class Song < ActiveRecord::Base belongs_to :album end
When I do the following in IRB for a cover album that is already in the database:
a = Album.find(1) a.title = "New title" a.cover_art.artist = "New Artist" a.save
It updates the album record, but not the CoverArt record. What am I doing wrong?
source share