views:

81

answers:

1

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>" }
A: 

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"
sscirrus
Good catch sscirrus!
tommasop