ActionController :: RoutingError(没有路由匹配[GET]“/system/attachments/photos/000/000/019/thumb/default.png”)

时间:2013-11-21 06:20:57

标签: ruby-on-rails ruby-on-rails-4 paperclip production-environment

我正在使用paperclip上传图片,并且它在开发时工作正常,但在生产服务器上却抛出错误

ActionController::RoutingError (No route matches [GET] "/system/attachments/photos/000/000/019/thumb/default.png")

我已经尝试了一切来修复它,但没有任何帮助我。以下是我的附件模型

class Attachment < ActiveRecord::Base

  belongs_to :testimonial
  has_attached_file :photo , :styles => { :thumb => "62x84!" },
                :path => ":rails_root/public/photo_attachment/:id/:style/:basename.:extension",
                :url => "/photo_attachment/:id/:style/:basename.:extension"

  validates_attachment_size :photo, :less_than => 5.megabytes
  validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png','image/gif']
end

请帮帮我!

1 个答案:

答案 0 :(得分:1)

:rails_root更改为Rails.root

:path => "#{Rails.root}/public/photo_attachment/:id/:style/:basename.:extension"

通过此更改,您上传的任何新图像都可以使用,但旧图像不起作用,因为已存储在db中的图像路径不正确。