【发布时间】:2015-05-11 15:37:54
【问题描述】:
我在 heroku 上部署了我的项目。
crackeryourwardrobe.heroku.com 是我的网站。
当我点击 facebook 登录时,我在 heroku 日志中收到此错误
PG::UndefinedColumn: ERROR: column "user_id" does not exist
SELECT "products".* FROM "products" WHERE (user_id = 1)
我的观点.rb
<% if session[:user_id] %>
<% @account_products.order(created_at: :desc).in_groups_of(3) do |product_group| %>
<div class = "row">
<% product_group.compact.each do |product| %>
<div class="col-md-4">
products.rb 类产品
wardrobe_item.rb 类 WardrobeItem
用户.rb
class User < ActiveRecord::Base
has_many :wardrobe_items, dependent: :destroy
数据库.yml
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
schema.rb
create_table "products", force: true do |t|
t.string "title"
t.text "brand"
t.string "image_url"
t.decimal "price"
t.datetime "created_at"
t.datetime "updated_at"
t.string "item"
t.integer "user_id", limit: 255
产品.rb
class Product < ActiveRecord::Base
has_many :line_items, dependent: :destroy
has_many :wardrobe_item, dependent: :destroy
mount_uploader :item, ItemUploader
end
wardrobe_item.rb
class WardrobeItem < ActiveRecord::Base
belongs_to :product
belongs_to :user
end
schema.rb
ActiveRecord::Schema.define(version: 20150310085128) do
create_table "line_items", force: true do |t|
t.integer "product_id"
t.integer "cart_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "quantity", default: 1
end
create_table "products", force: true do |t|
t.string "title"
t.text "brand"
t.string "image_url"
t.decimal "price"
t.datetime "created_at"
t.datetime "updated_at"
t.string "item"
t.integer "user_id", limit: 255
end
create_table "stores", force: true do |t|
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "users", force: true do |t|
t.string "provider"
t.string "uid"
t.string "name"
t.string "oauth_token"
t.datetime "oauth_expires_at"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "cart_id"
t.integer "wardrobe_item_id"
end
create_table "wardrobe_items", force: true do |t|
t.integer "product_id"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
我不知道如何解决它......请帮助......请......
【问题讨论】:
-
你跑
heroku rake db:migrate了吗? -
可能是错过了特定的迁移。尝试运行
heroku rake db:migrate:up VERSION=your_migration_file_version。 -
ActiveRecord::UnknownMigrationVersionError: No migration with version number 20150310075303
-
另外,我添加了 migration ,并提交并部署了收到的 heroku
-
未跟踪的文件:db/migrate/20150310075303_change_user_id_type_in_products.rb db/migrate/20150310085128_add_wardrobe_item_id_to_users.rb public/uploads/product/item/21/
标签: ruby-on-rails postgresql heroku