[英]Paperclip ActionController::RoutingError: No route matches [GET]
I am trying to run some Capybara/Poltergeist RSPEC integration tests. 我正在尝试运行一些Capybara / Poltergeist RSPEC集成测试。
Within my test, I am creating an image and 'uploading' it with Paperclip. 在测试中,我正在创建图像并使用Paperclip“上传”它。
Model: Platform::ContentImage
型号:
Platform::ContentImage
has_attached_file :attachment, {
styles: lambda { |a| a.instance.styles_by_image_type},
processors: [:thumbnail, :paperclip_optimizer],
paperclip_optimizer: {
nice: 19,
jpegoptim: { allow_lossy: true, strip: :all, max_quality: 75 },
jpegrecompress: {allow_lossy: true, quality: 3},
jpegtran: {progressive: true},
optipng: { level: 2 },
pngout: false
},
path: "#{'public/' if Rails.env.test?}content_image/:id/:style/:basename.:extension",
convert_options: { :all => '-auto-orient +profile "exif"' },
s3_headers: { 'Cache-Control' => 'max-age=31536000'}
}
In my application.rb
for testing environment 在我的
application.rb
用于测试环境
config.paperclip_defaults = {
url: "/public/:class/:id/:style/:basename.:extension"
}
My error returned 我的错误返回
ActionController::RoutingError:
No route matches [GET] "/system/platform/content_images/attachments/000/000/001/thumb/blue_night_swatch.jpg"
I am trying to display the image but I just can't seem to configure the URL properly. 我正在尝试显示图像,但似乎无法正确配置URL。 Since I override the default within the
Platform::ContentImage
model, it successfully creates the directory public/content_image
, however during tests, I can't seem to 'demodularize' the class name. 由于我在
Platform::ContentImage
模型中覆盖了默认值,因此它成功创建了目录public/content_image
,但是在测试期间,我似乎无法“解调”类名。 Can I specify the URL in the Platform::ContentImage
definition but only for test environments? 我可以在
Platform::ContentImage
定义中指定URL,但只能用于测试环境吗?
Put this message on the form and see why it is not saving: 将此消息放在表单上,看看为什么不保存:
<% if @portifolio.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@portifolio.errors.count, "error") %>
prohibited this portifolio from being saved:</h2>
<ul>
<% @portifolio.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.