Rails Paperclip未显示上传的图像

时间:2015-07-09 17:51:36

标签: ruby-on-rails paperclip

我刚刚开始使用paperclip gem,我遇到了一些问题。我在模型文件中设置了路径和网址,例如:

@Echo off
SET LOGFILE=MyLogFile.txt
call :Logit >> %LOGFILE% 
exit /b 0

当我从表单发送它时,服务器会将文件保存在应该执行的位置,但是当我检查以下网址时: mysite.com/public/images/guests/medium/1.jpg那里有路由错误。 我不知道该怎么做,能帮助我吗?

提前致谢!

2 个答案:

答案 0 :(得分:0)

网址应

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

而路径应该是

:path => ":rails_root/public/assets/images/guests/:style/:id/:basename.:extension"

答案 1 :(得分:0)

试试这个

has_attached_file : picture, 
  :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
:url => "/system/:attachment/:id/:style/:filename", 
:styles => { :medium => "500x500>", :thumb => "120x90#" },
:default_url => "path to default image"