Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails ActionController::RoutingError(没有与[GET]";/system/attachments/photos/000/000/019/thumb/default.png;匹配的路由)_Ruby On Rails_Ruby On Rails 4_Paperclip_Production Environment - Fatal编程技术网

Ruby on rails ActionController::RoutingError(没有与[GET]";/system/attachments/photos/000/000/019/thumb/default.png;匹配的路由)

Ruby on rails ActionController::RoutingError(没有与[GET]";/system/attachments/photos/000/000/019/thumb/default.png;匹配的路由),ruby-on-rails,ruby-on-rails-4,paperclip,production-environment,Ruby On Rails,Ruby On Rails 4,Paperclip,Production Environment,我用回形针上传图像,它在开发中运行良好,但在生产服务器上它抛出错误 ActionController::RoutingError (No route matches [GET] "/system/attachments/photos/000/000/019/thumb/default.png") 我已经尽了一切努力来修复它,但没有任何帮助。下面是我的附件模型 class Attachment < ActiveRecord::Base belongs_to :testimonial

我用回形针上传图像,它在开发中运行良好,但在生产服务器上它抛出错误

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
类附件{:thumb=>“62x84!”,
:path=>“:rails\u root/public/photo\u attachment/:id/:style/:basename.:extension”,
:url=>“/photo_attachment/:id/:style/:basename.:extension”
验证\u附件\u大小:照片,:小于=>5.MB
验证附件内容类型:照片、内容类型=>['image/jpeg'、'image/png'、'image/gif']
结束

请帮帮我

:rails\u root
更改为
rails.root

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

通过此更改,您上载的任何新图像都将正常工作,但旧图像无效,因为数据库中已存储的图像路径不正确。

更改
:rails\u root
rails.root

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

通过此更改,您上载的任何新图像都将正常工作,但旧图像无法正常工作,因为已存储在db中的图像路径不正确。

但其在开发环境中存储的图像会对生产产生影响吗?比较存储在开发db和生产db中的图像路径,它们必须是不同的。您的
:url
选项似乎也不正确。它应该是
:url=>“/public/photo_attachment/:id/:style/:basename.:extension”
,但它在开发环境中存储映像,这会对生产造成任何影响吗?比较存储在开发数据库和生产数据库中的映像路径,它们必须是不同的。您的
:url
选项似乎也不正确。它应该是
:url=>“/public/photo\u attachment/:id/:style/:basename.:extension”