Heroku - ActionView :: Template :: Error(PG :: Error:错误:列category_products.desc不存在 [英] Heroku - ActionView::Template::Error (PG::Error: ERROR: column category_products.desc does not exist
问题描述
我正在使用RailsAdmin,这是我在RailsAdmin中单击我的模型 CategoryProduct
时遇到的错误。
在2012-12-12已启动GET/ admin / category_product为67.230.41.62 -21 23:20:07 +0000
2012-12-21T23:20:07 + 00:00 app [web.1]:
2012-12-21T23:20:07 + 00:00 app [web.1]:ActionView :: Template :: Error(PG :: Error:错误:column category_products.desc does not exist
2012-12-21T23:20:07 + 00:00 app [web。 1]:LINE 1:... ry_products。* FROMcategory_productsORDER BY category_p ...
2012-12-21T23:20:07 + 00:00 app [web.1]:^
2012-12-21T23:20:07 + 00:00 app [web.1]::SELECTcategory_products。* FROMcategory_productsORDER BY category_products。desc LIMIT 20 OFFSET 0):
2012- 12-21T23:20:07 + 00:00 app [web.1]:120:%tbody
2012-12-21T23:20:07 + 00:00 app [web.1]:121: - @ objects.each do | object |
2012-12-21T23:20:07 + 00:00 app [web.1]:122:%tr
2012-12-21T23:20:07 + 00:00 app [web.1 ]:123:%td
2012-12-21T23:20:07 + 00:00 app [web.1]:124:= check_box_tagbulk_ids [],object.id,false
2012 -12-21T23:20:07 + 00:00 app [web.1]:125: - if @other_left_link || = other_left&& index_path(params.except('set')。merge(params [:set] .to_i!= 1?{:set =>(params [:set] .to_i - 1)}:{}))
2012-12-21T23:20:07 + 00:00 app [web.1]:126:%td.other.left = link_to...,@other_left_link,:class => 'pjax'^
这些是我的类别
,产品
& category_product
models:
Category.rb
#==架构信息
#
#表名称:类别
#
# id:integer不为null,主键
#name:string(255)
#created_at:datetime不为空
#updated_at:datetime不为空
#
class Category< ActiveRecord :: Base
attr_accessible:name
has_many:category_products do
def with_products
包含(:product)
end
end
has_many:products,:through => :category_products
def top_products(number)
category_products.with_products.order(purchases_count DESC)。limit(number).map {| c | c.product}#含产品
结束
结束
Product.rb
#==模式信息
#
#表名:产品
#
#id:integer不为null,主键
#name:string(255)
#description:string(255)
#price:float
#vendor_id:integer
#created_at:datetime not null
#updated_at:datetime not null
#image:string(255)
#
class产品< ActiveRecord :: Base
attr_accessible:name,:description,:price,:vendor_id,:image,:category_ids
mount_uploader:image,ImageUploader
elongs_to:vendor
has_many:category_products do
def with_categories
包含(:category)
end
end
$ b has_many:categories,:through => :category_products
def top_categories(number)
category_products.with_categories.order(purchases_count DESC)。limit(number).map {| c | c.category}#包含的类别
结束
结束
Category_Product
#==模式信息
#
#表名:category_products
#
#id:整数不为空,主键
#product_id:整数
#category_id:整数
#purchases_count:整数缺省值(0)
#created_at:datetime not null
#updated_at:datetime not null
#
class CategoryProduct< ActiveRecord :: Base
attr_accessible:product_id,:category_id,:purchases_count
$ b belongs_to:产品
belongs_to:类别
validates_uniqueness_of:product_id,:scope = > :category_id
end
有什么想法可能导致这种情况?
谢谢。
原来问题出在Heroku身上(我认为) / p>
我对代码库进行了另一次更新,这个问题似乎消失了。
I am using RailsAdmin and this is the error I get when I click on my model CategoryProduct
within RailsAdmin.
This is what the error looks like:
Started GET "/admin/category_product" for 67.230.41.62 at 2012-12-21 23:20:07 +0000
2012-12-21T23:20:07+00:00 app[web.1]:
2012-12-21T23:20:07+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: column category_products.desc does not exist
2012-12-21T23:20:07+00:00 app[web.1]: LINE 1: ...ry_products".* FROM "category_products" ORDER BY category_p...
2012-12-21T23:20:07+00:00 app[web.1]: ^
2012-12-21T23:20:07+00:00 app[web.1]: : SELECT "category_products".* FROM "category_products" ORDER BY category_products. desc LIMIT 20 OFFSET 0):
2012-12-21T23:20:07+00:00 app[web.1]: 120: %tbody
2012-12-21T23:20:07+00:00 app[web.1]: 121: - @objects.each do |object|
2012-12-21T23:20:07+00:00 app[web.1]: 122: %tr
2012-12-21T23:20:07+00:00 app[web.1]: 123: %td
2012-12-21T23:20:07+00:00 app[web.1]: 124: = check_box_tag "bulk_ids[]", object.id, false
2012-12-21T23:20:07+00:00 app[web.1]: 125: - if @other_left_link ||= other_left && index_path(params.except('set').merge(params[:set].to_i != 1 ? {:set => (params[:set].to_i - 1)} : {}))
2012-12-21T23:20:07+00:00 app[web.1]: 126: %td.other.left= link_to "...", @other_left_link, :class => 'pjax'^
These are my category
, product
& category_product
models:
Category.rb
# == Schema Information
#
# Table name: categories
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class Category < ActiveRecord::Base
attr_accessible :name
has_many :category_products do
def with_products
includes(:product)
end
end
has_many :products, :through => :category_products
def top_products(number)
category_products.with_products.order("purchases_count DESC").limit(number).map {|c| c.product} # product included
end
end
Product.rb
# == Schema Information
#
# Table name: products
#
# id :integer not null, primary key
# name :string(255)
# description :string(255)
# price :float
# vendor_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# image :string(255)
#
class Product < ActiveRecord::Base
attr_accessible :name, :description, :price, :vendor_id, :image, :category_ids
mount_uploader :image, ImageUploader
belongs_to :vendor
has_many :category_products do
def with_categories
includes(:category)
end
end
has_many :categories, :through => :category_products
def top_categories(number)
category_products.with_categories.order("purchases_count DESC").limit(number).map {|c| c.category} # category included
end
end
Category_Product
# == Schema Information
#
# Table name: category_products
#
# id :integer not null, primary key
# product_id :integer
# category_id :integer
# purchases_count :integer default(0)
# created_at :datetime not null
# updated_at :datetime not null
#
class CategoryProduct < ActiveRecord::Base
attr_accessible :product_id, :category_id, :purchases_count
belongs_to :product
belongs_to :category
validates_uniqueness_of :product_id, :scope => :category_id
end
Any ideas what may be causing this?
Thanks.
Turns out the problem was on Heroku's side (I assume).
I did another push with a different update to the codebase and this problem seemed to go away.
这篇关于Heroku - ActionView :: Template :: Error(PG :: Error:错误:列category_products.desc不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!