我目前在做與圖像..我遇到錯誤CRUD「ExecJS :: ProgramError在產品#指數類型錯誤:對象不支持此屬性或方法」時,我在視圖中顯示的圖像爲什麼我的圖片標籤中的紅寶石不會工作在軌道上的窗戶
問:我應該如何顯示我的形象在我的看法?這是爲什麼?
注:我的朋友沒有安裝像imagemagik &回形針什麼。我也試過在我看來(資產/圖像文件夾),它不工作,以顯示靜態圖像
查看
<html>
<head>
<title>MY STORE!</title>
</head>
<body>
<h1><align="center"> WELCOME TO MY STORE</h1>
<%= link_to 'Add Product', new_product_path %>
<table border = "1" width="100%">
<tr>
<td>ID</td>
<td>Name</td>
<td>Image</td>
<td>Size</td>
<td>Price</td>
<td>Created At</td>
<td>Updated At</td>
<td>Action</td>
</tr>
<% @product.each do |p| %>
<tr>
<td><%= p.id %></td>
<td><%= p.name %></td>
<td><%= image_tag p.image %></td>
<td><%= p.size %></td>
<td><%= p.price %></td>
<td><%= p.created_at.strftime("%B, %d, %Y") %></td>
<td><%= p.updated_at.strftime("%B, %d, %Y") %></td>
<td>
<%= link_to 'View', product_path(p) %>
<%= link_to 'Edit', edit_product_path(p) %>
</td>
</tr>
<% end %>
</table>
</body>
</html>
模式
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170406144121) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "carts", force: :cascade do |t|
t.integer "product_id"
t.integer "price"
t.string "status"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "products", force: :cascade do |t|
t.string "name"
t.string "size"
t.float "price"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "image"
end
create_table "user", id: :integer, default: -> { "nextval('customers_id_seq'::regclass)" }, force: :cascade do |t|
t.string "full_name"
t.string "product_name"
t.string "size"
t.float "price"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_foreign_key "carts", "products"
end
請發送確切的錯誤訊息。 – mudasobwa
該圖像屬性的類型是什麼?它返回圖像本身,還是它的路徑(鏈接)字符串? – marmeladze
@marmeladze屬性/類型我的image列的是字符串(在pgAdmin的等效字符改變)。我也嘗試使用AT(符號)product.inspect,所有的數據是有 – Angel