11866

Why my image tag wont work in ruby on rails in windows

Question:

I am currently doing a CRUD with image.. Am encountering error "ExecJS::ProgramError in Products#index TypeError: Object doesn't support this property or method" when I displaying the image in my view

Question: How should I display my image in my view? Why is that?

NOTE: My friend didn't install anything like imagemagik & paperclip.. I also tried to display a static image in my view(assets/images folder) and its not working

<strong>View</strong>

<html> <head> <title>MY STORE!</title> </head> <body>

<align="center"> WELCOME TO MY STORE

<%= 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>

<strong>Schema</strong>

# 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

Answer1:

The error is commonly related to a CoffeeScript compatibility issue with Windows. Downgrading the gem should solve it.

Locate your coffee-script-gem and change it for the following:

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

Then run:

bundle update coffee-script-source

*Please check where the error points to (file and line) if this solution doesn't work, and update your question.

Recommend

  • How to pass attribute data by clicking on image?
  • Nested resource with Atom Feed Helper
  • How to count all the likes that User has done on my specific items (Rails)
  • Cleaning up view ruby logic and separating concerns into model/controller
  • Show records ordered with maximum price first in PHP & MySQL
  • Find JSON nested nodes using multiple string values
  • Hector: how to query parts of a Composite Type
  • Magento get URL before current
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • Implementing “partial void” in VB
  • Sending HTML Form Data to Spring REST Web Service
  • converting text file into xml using php?
  • How to revert to previous XCode version?
  • Not able to aggregate on nested fields in elasticsearch
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • GridView breaks while scrolling
  • How to change the font size of a single index for UISegmentedControl?
  • Time complexity of a program which involves multiple variables
  • Python urlparse: small issue
  • Atlas images wrong size on iPad iOS 9
  • Change multiple background-images with jQuery
  • FileReader+canvas image loading problem
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Android screen density dpi vs ppi
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • Incrementing object id automatically JS constructor (static method and variable)
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Change an a tag attribute in JavaScript based on screen width
  • what is the difference between the asp.net mvc application and asp.net web application
  • How to get next/previous record number?
  • XCode can't find symbols for a specific iOS library/framework project
  • Confusion with PayPal's monthly billing cycle
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Free memory of cv::Mat loaded using FileStorage API
  • Getting Messege Twice Using IMvxMessenger
  • How to stop GridView from loading again when I press back button?
  • python draw pie shapes with colour filled
  • unknown Exception android