2016-01-15 77 views
1

我正在开发一个导轨项目。我目前正在设置电子邮件功能,并正在测试它。我正在使用letter opener,haml,并使用Mailchimp的email templates之一。导轨4 - 图像无法加载

我目前使用image_tag链接到我想要显示的图像。

当它是这样写的;

= image_tag 'my_image.png', id: 'headerImage', :style => "max-width:600px;", "mc:allowdesigner" => "", "mc:allowtext" => "", "mc:edit" => "header_image", "mc:label" => "header_image", :alt => 'alt text' 

我在html中得到了破碎的图像。当它是这样写的;

= image_tag 'my_image', id: 'headerImage', :style => "max-width:600px;", "mc:allowdesigner" => "", "mc:allowtext" => "", "mc:edit" => "header_image", "mc:label" => "header_image", :alt => 'alt text' 

我得到

Asset was not declared to be precompiled in production. Add Rails.application.config.assets.precompile += %w(my_image) to config/initializers/assets.rb and restart your server

我assets.rb看起来像这样;

Rails.application.config.assets.precompile += %w(my_image)我重新启动服务器。我也尝试使用相对路径手动链接图像,似乎没有任何工作。我也跑RAILS_ENV=development rake assets:precompile,但仍然没有。

我以前没有遇到过这个问题,但是好像rails并不想显示这个图像。也许这与letter_opener有关?

如果其他人遇到这个奇怪的问题,并知道该怎么做,或者他们如何修复它,任何帮助将不胜感激。

+0

哪个文件夹是my_image.png文件? –

+0

@PrakashMurthy my_image.png'与我的所有其他图像一起位于assets文件夹中 –

回答

0

链轮的最新版本存在问题,一直给开发者提出这个问题。尝试降级sprokets-rails宝石。把这个在您的Gemfile

gem 'sprockets-rails', '2.3.3' 

然后做bundle update sprockets-rails