2017-04-06 35 views
0

我目前在做與圖像..我遇到錯誤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 
+0

請發送確切的錯誤訊息。 – mudasobwa

+0

該圖像屬性的類型是什麼?它返回圖像本身,還是它的路徑(鏈接)字符串? – marmeladze

+0

@marmeladze屬性/類型我的image列的是字符串(在pgAdmin的等效字符改變)。我也嘗試使用AT(符號)product.inspect,所有的數據是有 – Angel

回答

1

電子rror通常與Windows的CoffeeScript兼容性問題有關。降級寶石應該可以解決它。

找到你的咖啡腳本的寶石,並改變它爲以下幾點:

gem 'coffee-script-source', '1.8.0' 

然後運行:

bundle update coffee-script-source 

*請檢查其中的錯誤點(文件和行),如果這解決方案不起作用,並更新您的問題。

+0

先生,你說的是去gemfile然後添加gem'coffee-script-source','1.8.0'來調整我的咖啡版本然後捆綁更新它? – Angel

+0

我不是「先生」,但是,是的,這就是我的意思:)試試看。還有一些其他的事情可以做,但從那裏開始。 – catch22

+0

Wups,對不起我的壞..我創造了另一個論壇http://stackoverflow.com/questions/43314458/rails-5-execjsprogramerror-in-collectionstesting你可以檢查一下嗎? – Angel