Windows 上的 Paperclip 和 JRuby 出现路径错误

发布于 2024-11-04 07:06:43 字数 4427 浏览 7 评论 0原文

我正在学习 Paperclip:在 Rails 中附加文件

我将这些代码放置在 show.html.erb 上显示图像。

<%= image_tag @user.photo.url %>
<%= image_tag @user.photo.url(:thumb) %>

在新页面上,我从计算机浏览文件 (.png),然后单击“创建”。 然后我得到了错误

很抱歉,出了点问题。

如何解决这个问题呢?请帮忙!

当我检查development.log时。我发现这些错误:

>Status: 500 Internal Server Error
    The system cannot find the path specified
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:486:in
    initialize'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:486:in
    new'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:486:in
    parse_multipart'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:471:in
    loop'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:471:in
    parse_multipart'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/request.rb:268:in
    parse_multipart'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/request.rb:146:in
    POST'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:15:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/params_parser.rb:15:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/session/cookie_store.rb:99:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/failsafe.rb:26:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:114:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/reloader.rb:34:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:108:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/static.rb:31:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:49:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in
    each'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/log_tailer.rb:17:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/content_length.rb:13:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/chunked.rb:15:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:67:in
    process'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:159:in
    process_client'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:158:in
    each'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:158:in
    process_client'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
    initialize'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
    new'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:268:in
    initialize'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:268:in
    new'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:268:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:38:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:111
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:31:in
    require'
    C:/jruby/jruby-1.5.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
    require'
    ./script/server:3
    ./script/server:2:in `load'
    -e:2

I'm learning about Paperclip: Attaching Files in Rails

I place these code to display image on show.html.erb

<%= image_tag @user.photo.url %>
<%= image_tag @user.photo.url(:thumb) %>

On new page, I browse a file (.png) from my computer and click create.
Then I got the error

We're sorry, but something went wrong.

How to solve this problem? Please help!

When I check on development.log. I found these errors:

>Status: 500 Internal Server Error
    The system cannot find the path specified
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:486:in
    initialize'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:486:in
    new'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:486:in
    parse_multipart'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:471:in
    loop'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:471:in
    parse_multipart'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/request.rb:268:in
    parse_multipart'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/request.rb:146:in
    POST'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:15:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/params_parser.rb:15:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/session/cookie_store.rb:99:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/failsafe.rb:26:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:114:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/reloader.rb:34:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:108:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/static.rb:31:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:49:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in
    each'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/log_tailer.rb:17:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/content_length.rb:13:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/chunked.rb:15:in
    call'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:67:in
    process'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:159:in
    process_client'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:158:in
    each'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:158:in
    process_client'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
    initialize'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
    new'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:268:in
    initialize'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:268:in
    new'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:268:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:38:in
    run'
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:111
    C:/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:31:in
    require'
    C:/jruby/jruby-1.5.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
    require'
    ./script/server:3
    ./script/server:2:in `load'
    -e:2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄与心 2024-11-11 07:06:43

我已经使用回形针宝石有一段时间了,我认为它很棒 - 所以不要灰心!

我能想到以下几点:

(1)您能否向我们展示您的用户模型代码?

(2) 您是否接受 PNG 文件作为有效的图像文件?像这样的东西:

validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/png', 'image/gif']

祝你好运!

I've been using the paperclip gem for quite awhile, and I think its awesome - So don't lose heart!

Here's a couple of things I can think of:

(1) Could you show us your User model code?

(2) Did you accept PNG files as a valid image file? Something like this:

validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/png', 'image/gif']

Good luck!

七堇年 2024-11-11 07:06:43

您的上传目录似乎无效。
您收到的消息是 Windows 错误消息。
您需要为模型中的图片指定正确的上传路径。
例如:

has_attached_file :photo,
    :url  => ":style/:basename.:extension",
    :path  => ":style/:basename.:extension",
    :storage => :filesystem

我希望它有帮助。

It appears that your upload directory is not valid.
The message you get is a Windows error message.
You need to specify a correct upload path for you pictures in your model.
For example:

has_attached_file :photo,
    :url  => ":style/:basename.:extension",
    :path  => ":style/:basename.:extension",
    :storage => :filesystem

I hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文