Josh
2008-Dec-23 04:15 UTC
Updating model with has_one association - do not want to update associated model
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---