【发布时间】:2010-09-27 07:59:14
【问题描述】:
我已在我的系统上成功设置了 Paperclip 和 ImageMagick,文件正在正确上传、调整大小并保存到正确的文件夹中。
我尝试在我的视图中显示这些图像:
<%= image_tag @customer.logo.url(:medium) %>
没有图像显示。当我转到图片的直接网址时,我得到:
Routing Error
No route matches "/images/assets/logos/1/medium/corplogo.jpg" with {:method=>:get}
这是一个仍在开发中并在 Windows 上运行的本地服务器。我的表单是多部分的:
<% form_for @customer, :url => {:action => "update", :id => @customer}, :html => {:multipart => true, :id => "myform"} do |f| %>
----- 开发服务器 ------
Processing ApplicationController#index (for 127.0.0.1 at 2010-09-27 04:38:33) [G 东部时间] 参数:{"1285570273"=>nil}
ActionController::RoutingError(没有路由匹配“/images/assets/logos/1/medium/corplogo.jpg”和{:method=>:get}): haml (3.0.15) rails/./lib/sass/plugin/rack.rb:41:in `call'
渲染救援/布局(not_found)
-----型号------
has_attached_file :logo,
:url => "assets/logos/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/logos/:id/:style/:basename.:extension",
:styles => {:medium => "300x300>", :thumb => "100x100>" }
【问题讨论】:
-
要检查的三件事:您的回形针设置中是否定义了 :medium 尺寸?图像在给定路径上吗?你重启服务器了吗?
-
你能展示一下你开发服务器的所有调试吗?
-
@dombesz - :medium 在设置中定义,图像在正确的位置,我已经重新启动了服务器。 :)
-
@tommasop - 我已经添加了上面的数据。谢谢
-
你能出示
has_attached_file声明吗?
标签: ruby-on-rails routes paperclip rmagick