Kad Kerforn
2008-Feb-10 14:33 UTC
ActiveRecord - counter_cache => true no update of record
Hello , I''ld need some help (read it could be a bug .. patch coming in 2.0.3 ?) I have hm / bt relationships class User < ActiveRecord::Base has_many :infos, :dependent => :destroy class Info < ActiveRecord::Base belongs_to :user , :counter_cache => true when creating a new info instance, the ''infos_count'' column in the users table is not incremented infos_controller.rb def create @info = Info.new(params[:info]) @info.valid_until = params[:valid_until] .. if @info.save current_user.infos << @info #user_id inserted in info but infos_count not updated in user record current_user.reload else format.html { render :action => "new" } end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---