2015-12-26 67 views
0

我是新來的rails 4我想添加多個圖像在我的app.i嘗試修復給出這個post。我結束了新的錯誤。Mysql2 ::錯誤:未知列在where子句

Mysql2::Error: Unknown column 'pictures.product_id' in 'where clause': SELECT pictures.* FROM pictures WHERE pictures.product_id = 9 

schema.rb

create_table "products", force: :cascade do |t| 
t.datetime "created_at",      null: false 
t.datetime "updated_at",      null: false 
t.string "name",    limit: 255 
t.integer "price",    limit: 4 
t.text  "description",  limit: 65535 
t.text  "reason",    limit: 65535 
t.integer "user_id",   limit: 4 
t.string "image_file_name", limit: 255 
t.string "image_content_type", limit: 255 
t.integer "image_file_size", limit: 4 
t.datetime "image_updated_at" 
t.string "status",    limit: 255 
t.integer "category_id",  limit: 4 
end 

有人可以幫我這個

+0

你有''在表pictures' product_id'? – Pavan

+0

你可以粘貼表格定義嗎? –

回答

0

按照您的架構你沒有在產品表PRODUCT_ID列。

如果你想的product_id列比你必須需要喲使用ALTER TABLE查詢,並在產品中添加的product_id 表像

ALTER TABLE products 
ADD COLUMN product_id INT NOT NULL AUTO_INCREMENT FIRST, 
ADD PRIMARY KEY (product_id); 
相關問題