启动了一个新的Rails项目并进行了很好的设置但是当我使用image_tag
尝试显示app/assets/images
中存在的图像(magnum.jpg)时出现ERROR Errno::EINVAL
错误。已经有一段时间了,似乎无法过去。
使用的Rails版本是4.2.3
以下是我的观点:
<div class="panel panel-default">
<div class="panel-heading">
<p>
Magnum
</p>
</div>
<div class="panel-body">
<%= image_tag("magnum.jpg", :class => "img-responsive", :alt => "test image") %>
<p>
Lorem ipsum
</p>
</div>
</div>
这是堆栈跟踪:
Started GET "/assets/magnum-2630b6237ccc91601cd5f59ac6653ea110dc75e787a38ef596c7
0fbbcfb7b3c3.jpg" for ::1 at 2015-08-20 23:12:52 +0100
[2015-08-20 23:12:53] ERROR Errno::EINVAL: Invalid argument @ rb_sysopen - C:/Us
ers/ollaollu/Desktop/Project/webstore/C:/Users/ollaollu/Desktop/Project/webstore
/app/assets/images/magnum.jpg
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sprockets-3.3.2/lib
/sprockets/asset.rb:99:in `binread'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sprockets-3.3.2/lib
/sprockets/asset.rb:99:in `source'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sprockets-3.3.2/lib
/sprockets/asset.rb:107:in `to_s'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sprockets-3.3.2/lib
/sprockets/asset.rb:154:in `each'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack
/body_proxy.rb:31:in `each'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack
/body_proxy.rb:31:in `each'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack
/body_proxy.rb:31:in `each'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack
/body_proxy.rb:31:in `each'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack
/body_proxy.rb:31:in `each'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack
/body_proxy.rb:31:in `each'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack
/body_proxy.rb:31:in `each'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack
/handler/webrick.rb:112:in `service'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:138:in
`service'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `
run'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/server.rb:295:in `blo
ck in start_thread'
Gemfile锁:
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.3)
actionview (= 4.2.3)
activesupport (= 4.2.3)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.3)
activesupport (= 4.2.3)
globalid (>= 0.3.0)
activemodel (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
activerecord (4.2.3)
activemodel (= 4.2.3)
activesupport (= 4.2.3)
arel (~> 6.0)
activesupport (4.2.3)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (6.0.2)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.8.0)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.6.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.4)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.8.0)
multi_json (1.11.2)
nokogiri (1.6.6.2-x86-mingw32)
mini_portile (~> 0.6.0)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.3)
actionmailer (= 4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
activemodel (= 4.2.3)
activerecord (= 4.2.3)
activesupport (= 4.2.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.3)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.3)
actionpack (= 4.2.3)
activesupport (= 4.2.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
json (~> 1.4)
sass (3.4.16)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
sprockets (3.3.2)
rack (~> 1.0)
sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10-x86-mingw32)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
tzinfo-data (1.2015.6)
tzinfo (>= 1.0.0)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
web-console (2.2.1)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
PLATFORMS
x86-mingw32
DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
coffee-script-source (= 1.8.0)
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.3)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
sqlite3
turbolinks
tzinfo-data
uglifier (>= 1.3.0)
web-console (~> 2.0)
答案 0 :(得分:2)
能够将问题追溯到Sprocket版本3.3.2 / 3.3.3和资产管道。
指定Sprockets版本3.2.0解决了问题