Rails 4 / Heroku内部服务器错误在390毫秒内+回形针

尼尔

我有一个网络应用程序,要求用户更新图像。我已经使用Paperclip gem安装了它。这适用于本地主机。但是在Heroku上,它确实上传了图像,但是当他们单击“后退”按钮查看listings.index文件时,出现“内部服务器错误”。

20:       <tr>
2014-07-21T16:18:42.727180+00:00 app[web.1]: Completed 500 Internal Server Error in 390ms
2014-07-21T16:18:42.726840+00:00 app[web.1]:   Rendered listings/index.html.erb within layouts/application (383.4ms)
2014-07-21T16:18:42.729352+00:00 app[web.1]:     18:   <tbody>
2014-07-21T16:18:42.729353+00:00 app[web.1]:     19:     <% @listings.each do |listing| %>
2014-07-21T16:18:42.726897+00:00 app[web.1]:   Rendered listings/index.html.erb within layouts/application (383.4ms)
2014-07-21T16:18:42.727145+00:00 app[web.1]: Completed 500 Internal Server Error in 390ms
2014-07-21T16:18:42.729361+00:00 app[web.1]:     24:         <td><%= listing.price %></td>
2014-07-21T16:18:42.729366+00:00 app[web.1]: 
2014-07-21T16:18:42.729418+00:00 app[web.1]:     21:         <td><%= image_tag listing.image.url(:small) %></td>
2014-07-21T16:18:42.729422+00:00 app[web.1]:     24:         <td><%= listing.price %></td>
2014-07-21T16:18:42.729410+00:00 app[web.1]: ActionView::Template::Error (Path '/small/1_mangos.jpg' not found):
2014-07-21T16:18:42.729365+00:00 app[web.1]:   app/views/listings/index.html.erb:19:in `_app_views_listings_index_html_erb___3465202124191925527_69930398073120'
2014-07-21T16:18:42.729360+00:00 app[web.1]:     23:         <td><%= listing.description %></td>
2014-07-21T16:18:42.729440+00:00 app[web.1]:   app/views/l
istings/index.html.erb:19:in `_app_views_listings_index_html_erb___3465202124191925527_69930398073120'
2014-07-21T16:18:42.729357+00:00 app[web.1]:     21:         <td><%= image_tag listing.image.url(:small) %></td>

listings.index.html.erb

<h3>Product Listings </h3>

<table class="table table-striped">
  <thead>
    <tr>
      <th>Image</th>
      <th>Name</th>
      <th>Description</th>
      <th>Price</th>
      <th>Quantity</th>
      <th>Company</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    <% @listings.each do |listing| %>
      <tr>
        <td><%= image_tag listing.image.url(:small) %></td>
        <td><%= listing.name %></td>
        <td><%= listing.description %></td>
        <td><%= listing.price %></td>
        <td><%= listing.quantity %></td>
        <td><%= listing.company %></td>
        <td><%= link_to 'Show', listing, class: "btn btn-link" %></td>
        <td><%= link_to 'Edit', edit_listing_path(listing), class: "btn btn-link" %></td>
        <td><%= link_to 'Destroy', listing, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-link" %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New Product Listing', new_listing_path, class: "btn btn-primary" %>

show.html.erb

<p id="notice"><%= notice %></p>

<div class="row">
  <div class="col-md-6">
    <div class="thumbnail">
        <%= image_tag @listing.image.url %>
    </div>
  </div>

<div class="col-md-6">
  <h3><%= @listing.name %></h3>
   <p><%= @listing.price %></p>
  <p><%= @listing.description %></p>
  <p><%= @listing.quantity %></p>
  <p><%= @listing.company %></p>

<%= link_to 'Edit', edit_listing_path(@listing), class: "btn btn-link" %> |
<%= link_to 'Back', listings_path, class: "btn btn-link" %>

宝石文件

来源' https://rubygems.org '

ruby "2.0.0"
gem 'rails', '4.0.4'
gem 'sass-rails', '~> 4.0.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'bootstrap-sass'
gem 'paperclip', github: 'thoughtbot/paperclip' 
gem 'jbuilder', '~> 1.2'
gem "paperclip-dropbox", ">= 1.1.7"
gem "figaro"

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

group :development, :test do
  gem 'sqlite3'
end


at=info method=GET path="/" host=sincurudemo.herokuapp.com request_id=9c2482eb-dd09-42a0-80fc-905a729209dd fwd="185.30.24.132" dyno=web.1 connect=11 service=468 status=500 bytes=1090
2014-07-21T17:19:33.329057+00:00 app[web.1]:   Rendered listings/index.html.erb within layouts/application (444.7ms)
2014-07-21T17:19:33.329212+00:00 app[web.1]: Completed 500 Internal Server Error in 446ms
2014-07-21T17:19:33.331035+00:00 app[web.1]: 
2014-07-21T17:19:33.331056+00:00 app[web.1]: ActionView::Template::Error (Path '/small/1_mangos.jpg' not found):
2014-07-21T17:19:33.329050+00:00 app[web.1]:   Rendered listings/index.html.erb within layouts/application (444.7ms)
2014-07-21T17:19:33.329199+00:00 app[web.1]: Completed 500 Internal Server Error in 446ms
2014-07-21T17:19:33.331061+00:00 app[web.1]:     20:       <tr>
2014-07-21T17:19:33.331060+00:00 app[web.1]:     19:     <% @listings.each do |listing| %>
2014-07-21T17:19:33.331063+00:00 app[web.1]:     22:         <td><%= listing.name %></td>
2014-07-21T17:19:33.331066+00:00 app[web.1]:     24:         <td><%= listing.price %></td>
2014-07-21T17:19:33.331067+00:00 app[web.1]:   app/views/listings/index.html.erb:21:in `block in _app_views_listings_index_html_erb__108501327453821717_70092909422920'
2014-07-21T17:19:33.331070+00:00 app[web.1]: 
2014-07-21T17:19:33.331077+00:00 app[web.1]: 
2014-07-21T17:19:33.331079+00:00 app[web.1]: ActionView::Template::Error (Path '/small/1_mangos.jpg' not found):
2014-07-21T17:19:33.331058+00:00 app[web.1]:     18:   <tbody>
2014-07-21T17:19:33.331080+00:00 app[web.1]:     18:   <tbody>
2014-07-21T17:19:33.331081+00:00 app[web.1]:     19:     <% @listings.each do |listing| %>
2014-07-21T17:19:33.331072+00:00 app[web.1]: 
2014-07-21T17:19:33.331082+00:00 app[web.1]:     20:       <tr>
2014-07-21T17:19:33.331062+00:00 app[web.1]:     21:         <td><%= image_tag listing.image.url(:small) %></td>
2014-07-21T17:19:33.331065+00:00 app[web.1]:     23:         <td><%= listing.description %></td>
2014-07-21T17:19:33.331069+00:00 app[web.1]:   app/views/listings/index.html.erb:19:in `_app_views_listings_index_html_erb__108501327453821717_70092909422920'
2014-07-21T17:19:33.331083+00:00 app[web.1]:     21:         <td><%= image_tag listing.image.url(:small) %></td>
2014-07-21T17:19:33.331085+00:00 app[web.1]:     23:         <td><%= listing.description %></td>
2014-07-21T17:19:33.331087+00:00 app[web.1]:     24:         <td><%= listing.price %></td>
2014-07-21T17:19:33.331089+00:00 app[web.1]:   app/views/listings/index.html.erb:19:in `_app_views_listings_index_html_erb__108501327453821717_70092909422920'
2014-07-21T17:19:33.331084+00:00 app[web.1]:     22:         <td><%= listing.name %></td>
2014-07-21T17:19:33.331088+00:00 app[web.1]:   app/views/listings/index.html.erb:21:in `block in _app_views_listings_index_html_erb__108501327453821717_70092909422920'

listing.rb文件

class Listing < ActiveRecord::Base
  if Rails.env.development?
    has_attached_file :image, :styles => { :small => "50x", :thumb => "100x100>" }, :default_url => "default.jpg"
    validates_attachment_content_type :image, :content_type => %w(image/jpeg image/jpg image/png)

  else
    has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg",
        :storage => :dropbox,
        :dropbox_credentials => Rails.root.join("config/dropbox.yml"),
        :path => ":style/:id_:filename"
  end
  validates_attachment_content_type :image, :content_type => %w(image/jpeg image/jpg image/png)
  validates_attachment_presence :image
end
维奇

自Rails 3.2以来,在Heroku上的Rails 4应用程序中提供资产的行为已更改。

首先,启用服务静态资产production.rbconfig.serve_static_assets = true

然后,将rails_12factor gem添加到您的Gemfilegem 'rails_12factor', group: :production

同时,(每与OP的讨论),你没有:small你的自定义键has_attached_file用于Listing.rb在非开发环境:

if Rails.env.development?
  has_attached_file :image, :styles => { :small => "50x", :thumb => "100x100>" }, :default_url => "default.jpg"
  validates_attachment_content_type :image, :content_type => %w(image/jpeg image/jpg image/png)

else
  has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg",
    :storage => :dropbox,
    :dropbox_credentials => Rails.root.join("config/dropbox.yml"),
    :path => ":style/:id_:filename"
end

因此,一旦您:small => "50x"else块中添加它就应该起作用。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Ruby on Rails-回形针错误

来自分类Dev

Rails 4 Angularjs回形针如何上传文件

来自分类Dev

带Devise和回形针的Rails 4

来自分类Dev

Rails 4 Angularjs回形针如何上传文件

来自分类Dev

Rails4 +回形针(无法从模型克隆)

来自分类Dev

Rails 4-回形针-Dropbox生产问题

来自分类Dev

带有Devise的Rails 4回形针,文件保存错误

来自分类Dev

Rails 4:回形针错误发布模型缺少'image_file_name'的attr_accessor必需

来自分类Dev

如何创建自定义回形针处理器以检索图像尺寸Rails 4

来自分类Dev

Rails 4-使用自定义回形针附件处理器进行参数解析的顺序

来自分类Dev

Rails 4,回形针,Amazon S3配置Amazon路径

来自分类Dev

Ruby on Rails 4-重复的回形针验证消息

来自分类Dev

Rails 4带有回形针的多个文件附件

来自分类Dev

Rails 4-回形针-使用DATA URI上传图像

来自分类Dev

Rails 4:使用回形针上传多张图片

来自分类Dev

使用回形针上传base64图像-Rails 4

来自分类Dev

Rails 4-回形针-使用DATA URI上传图像

来自分类Dev

Rails 4:使用回形针上传多张图片

来自分类Dev

Rails 4 +回形针:制作默认的个人资料图片

来自分类Dev

Rails 4回形针FactoryGirl文件上传

来自分类Dev

Rails 4 SSL错误停止使用回形针直接进行s3上传

来自分类Dev

Rails +回形针RangeError

来自分类Dev

Rails回形针:: AdapterRegistry :: NoHandlerError

来自分类Dev

Rails中的回形针问题

来自分类Dev

编辑Rails文件(回形针)

来自分类Dev

Ruby on Rails回形针问题

来自分类Dev

回形针和ImageMagick发生未知错误-Rails 2

来自分类Dev

尝试使用回形针上传图像时,Rails出现错误

来自分类Dev

Rails文件上载(回形针)编辑

Related 相关文章

热门标签

归档