我正在使用图片进行CRUD ..当我在视图中显示图像时遇到错误“产品中的ExecJS :: ProgramError #index TypeError:对象不支持此属性或方法”
问题:如何在视图中显示我的图像?那是为什么?
注意:我的朋友没有安装像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
答案 0 :(得分:1)
该错误通常与Windows的CoffeeScript兼容性问题有关。降级宝石应该解决它。
找到您的coffee-script-gem并更改以下内容:
gem 'coffee-script-source', '1.8.0'
然后运行:
bundle update coffee-script-source
*如果此解决方案不起作用,请检查错误指向的位置(文件和行),并更新您的问题。