开发者

Problem viewing photos in Paperclip - routes error

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",
  开发者_StackOverflow中文版  :styles => {:medium => "300x300>", :thumb => "100x100>" }


I found the answer to the problem, and it lies with the url declaration in the model.

Instead of:

:url => "assets/logos/:id/:style/:basename.:extension"

it should be:

:url => "/assets/logos/:id/:style/:basename.:extension"


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜