在回形针中查看照片时出现问题 - 路线错误
我已在系统上成功设置 Paperclip 和 ImageMagick,并且文件正在正确上传、调整大小并保存到正确的文件夹中。
我尝试在我的视图中显示这些图像:
<%= image_tag @customer.logo.url(:medium) %>
没有显示图像。当我访问图像的直接 url 时,我得到:
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| %>
------ 开发服务器 ------
处理 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>" }
I have set up Paperclip and ImageMagick successfully on my system, and files are uploading correctly, being resized, and and being saved into the right folders.
I try to display those images in my view:
<%= image_tag @customer.logo.url(:medium) %>
No image is displayed. When I go to the image's direct url I get:
Routing Error
No route matches "/images/assets/logos/1/medium/corplogo.jpg" with {:method=>:get}
This is a local server still in development and running on Windows. My forms are multipart:
<% form_for @customer, :url => {:action => "update", :id => @customer}, :html => {:multipart => true, :id => "myform"} do |f| %>
------ Dev Server ------
Processing ApplicationController#index (for 127.0.0.1 at 2010-09-27 04:38:33) [G
ET]
Parameters: {"1285570273"=>nil}
ActionController::RoutingError (No route matches "/images/assets/logos/1/medium/corplogo.jpg" with {:method=>:get}):
haml (3.0.15) rails/./lib/sass/plugin/rack.rb:41:in `call'
Rendering rescues/layout (not_found)
------ Model ------
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>" }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了问题的答案,它在于模型中的 url 声明。
而不是:
应该是:
I found the answer to the problem, and it lies with the url declaration in the model.
Instead of:
it should be:
我使用“webrick”服务器时遇到此错误。我检查了“public/system”文件夹上的所有文件访问权限,它们都是正常的。
最后我切换到 apache/passenger,它有效,图像显示正确。
I got this error using the "webrick" server. and I check all the file access permission on my "public/system" folder, they are normal.
finally I switched to apache/passenger, it works, the images are displayed correctly.