Rails app trying to update a nonexistent column -
this on ruby 1.9.3 , rails 3.2.19. i'm not super experienced rails. today started having issue on our live server, works fine on development server.
whenever try give publication model new tags, error:
activerecord::statementinvalid (pg::undefinedcolumn: error: column "taggings_count" not exist line 1: update "tags" set "taggings_count" = oalesce("taggings_count", 0) + 1 "tags"."id" = 47: app/controllers/publications_controller.rb:162:in 'block in update' app/controllers/publications_controller.rb:161:in 'update'
and line 162 of controller is:
def update @publication = publication.find(params[:id]) if params[:clear_virtual_performances] @publication.virtual_performances.each {|vp| vp.destroy} end if media_id = params["selected_media"] pub_ids = @publication.publication_media_ids publicationmedia.update(@publication.publication_media_ids, [{:selected => false}] * pub_ids.length) publicationmedia.update(media_id, :selected => true) end respond_to |format| if @publication.update_attributes(params[:publication]) // <------------------- expire_fragments flash[:notice] = 'publication updated.' format.html { redirect_to(:action => 'show') } format.xml { head :ok } else load_extra_vars_for_edit_form category.in_slug(params[:default_category]) format.html { render :action => "edit" } format.xml { render :xml => @publication.errors, :status => :unprocessable_entity } end end end
however, column "taggings_count" not exist in tags , don't know why looking update in first place. in fact, table on has columns: id, name, position, category_id, , tag_group_id. here tag model:
class tag < activerecord::base has_many :taggings belongs_to :category belongs_to :tag_group attr_accessible :name, :position, :category_id, :tag_group_id end
if there more information should give please let me know; it's vital fixed possible. need error not happen, if means creating dummy column or something.
i guess have counter_cache
attribute defined in tagging, belongs_to :publication, counter_cache: true
. that's causing counter automagically increment.
you can either remove counter_cache: true
or make migration add column.
Comments
Post a Comment