Updating model with has_one association - do not want to update associated model


#1

I have two classes: Article and Update. When I try to update an
Article, it is NOT saving the instance, but is only saving the
associated Update object (which is valid).

class Article < ActiveRecord::Base
has_one :update, :as => :content, :dependent => :destroy
end

class Update < ActiveRecord::Base
belongs_to :content, :polymorphic => true, :readonly => true
end

class ArticlesController < ApplicationController
def update
@article = Article.find(params[:id])

if @article.update_attributes(params[:article])
  flash[:notice] = 'Article was successfully updated.'
  redirect_to(@article)
else
  render :action => 'edit'
end

end
end

When I check my log; however, you can see that only the Update object
was updated, not the Article object. Any thoughts on why? I haven’t
done much with Rails 2.2, but this is not the behavior I remember from
earlier versions.

Thanks,
Josh