Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asset Path Error in Spree / Ruby on Rails

I am setting up my second "spree" store in a local development environment to work on an ecommerce project using the Spree gem for RubyOnRails.

The first store works, but when I shut off the "rails server" for store1 and try to fire it up for store2, when I go to http://localhost:3000 I get this this error:


Sprockets::Rails::Helper::AbsoluteAssetPathError in Spree::Home#index

Showing /Users/pivot/.rvm/gems/ruby-2.0.0-p481/gems/spree_frontend-2.3.2/app/views/spree/shared/_head.html.erb where line #7 raised:

Asset names passed to helpers should not include the "/assets/" prefix. Instead of "/assets/favicon.ico", use "favicon.ico"

Extracted source (around line #7):

  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1" name="viewport">
  <%== meta_data_tags %>
  <%= canonical_tag(current_store.url) %>
  <%= favicon_link_tag image_path('favicon.ico') %> #THIS IS THE HIGHLIGHTED LINE
  <%= stylesheet_link_tag 'spree/frontend/all', :media => 'screen' %>
  <%= csrf_meta_tags %>
  <%= javascript_include_tag 'spree/frontend/all' %>

Trace of template inclusion: /Users/pivot/.rvm/gems/ruby-2.0.0-p481/gems/spree_frontend-2.3.2/app/views/spree/layouts/spree_application.html.erb


This error is coming from a spree view file, and the offending line is actually just passing in "favicon.ico" not "assets/favicon.ico", so I don't know what's going on.

like image 233
mattcrowe Avatar asked Sep 02 '14 23:09

mattcrowe


1 Answers

i encountered the same error. It's introduced by sprockets-rails 2.1.4, that requires no more the /assets prefix for favicon_link_tag.

Maybe for some reasons when spree 2.3.2 has been released, sprockets-rails gem was at 2.1.3 version.

I fix it editing the Gemfile.lock, changing manually the version of sprockets-rails from 2.1.4 to 2.1.3 (in my specific case no gems require exactly that version, check your Gemfile.lock to be sure of that!!!).

I suppose in future releases this will be fixed, so updating sprockets-rails gem will generate no more errors.

like image 198
dalzhe Avatar answered Nov 19 '22 09:11

dalzhe