2017-04-11 5 views
0

「app/assets/images/wholesale_analysis.png」のようなアセットパイプラインに画像があります。私のテンプレートでは、このタグは<%= image_tag("wholesale_analysis.png") %>ですが、画像が見つかりません。イメージタグに 'alt:'を指定しても、イメージではなくイメージタグのテキストが返されます。イメージタグはレイアウトでは機能しますが、テンプレートでは機能しません。何が起こっている? wholesale_analysis.pngまたはwholesaleanalysis.png と変更:レールコンソールの結果@KamilRoR画像タグが見つからない画像

...

`C:/Users/CMMC/Documents/Sites/cmmc/config/environments/development.rb:50:in 

block in <top (required)>': undefined method `config' for #<Rack::Sendfile:0x5321250> (NoMethodError) 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/railtie.rb:209:in `instance_eval' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/railtie.rb:209:in `configure' 
     from C:/Users/CMMC/Documents/Sites/cmmc/config/environments/development.rb:1:in `<top (required)>' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/engine.rb:600:in `block (2 levels) in <class:Engine>' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/engine.rb:599:in `each' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/engine.rb:599:in `block in <class:Engine>' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `instance_exec' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `run' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:55:in `block in run_initializers' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `each' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `tsort_each_child' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:415:in `call' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:in `each' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:in `call' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each' 
     from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:54:in `run_initializers' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:352:in `initialize!' 
     from C:/Users/CMMC/Documents/Sites/cmmc/config/environment.rb:5:in `<top (required)>' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:328:in `require' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:328:in `require_environment!' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:157:in `require_application_and_environment!' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:77:in `console' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!' 
     from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>' 
     from bin/rails:4:in `require' 
     from bin/rails:4:in `<main>' 
+0

ローカルまたはtest/production envで実行しますか? – Kamil

+0

開発環境にあります。 – Xenedra

+0

rails console( 'rails c')を起動し、値を取得する:Rails.application.config.assets.precompile – Kamil

答えて

0

なりましょう...私のファイルの名前は.html.erbではなく.htmlに変更されました。すべてが今働きます!ご意見ありがとうございました。

0

はのように、 "卸売" や "analysis.png" 間のファイル名のスペースを削除します同様にあなたのイメージタグは:

<%= image_tag("wholesale_analysis.png") %> 
+0

それを試したが、それでも動作しない:( – Xenedra

+0

@Jessicaまた、ファイル名からスペースを削除しましたか画像フォルダ内にある – amrrbakry

+0

はい、私はアンダースコアに置き換えました – Xenedra

0

私は、彼らは、CSSやJSファイルのようにプリコンパイルされるべきではない、あなたの公開/ direcotryに画像を置くために助言します。 あなたが本当にあなたの資産にそれらを持っているしたい場合は、試してみてください:<%= image_tag("/assets/wholesale_analysis.png") %>

+0

私は両方の提案を試みました...画像をパブリックディレクトリに入れ、画像タグを "/ assets /"を含むように変更しました。どちらもうまくいかなかった。 – Xenedra

0

@Xenedra資産/フォルダ内の画像を配置し、タグが、私は私の問題を修正し

<%= image_tag("wholesale_analysis.png") %> 
+0

まだ動作しません... – Xenedra

+0

rakeアセットを使用してアセットをプリコンパイルしよう:プリコンパイル、jus試してみてください – Aditya

関連する問題