Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Error Paperclip in production #1406

Closed
kraudio opened this Issue Nov 21, 2012 · 2 comments

Comments

Projects
None yet
1 participant

kraudio commented Nov 21, 2012

This image uploading, resizing this correctly, not only is giving error to view the image

GitHub Logo

Developing this perfect, but in Production shows the error:

Log

Started GET "/admin/computer/2?_pjax=%5Bdata-pjax-container%5D" for 127.0.0.1 at 2012-11-21 14:29:11 -0300
Processing by RailsAdmin::MainController#show as HTML
Parameters: {"_pjax"=>"[data-pjax-container]", "model_name"=>"computer", "id"=>"2"}
Rendered /Users/claudio/.rvm/gems/ruby-1.9.3-p327/gems/rails_admin-0.1.2/app/views/rails_admin/main/show.html.haml within layouts/rails_admin/pjax (122.5ms)
Completed 200 OK in 242ms (Views: 57.7ms | ActiveRecord: 174.9ms)

Started GET "/system/computer/cfotos_2_thumb_cfotos.jpg?1353518875" for 127.0.0.1 at 2012-11-21 14:29:12 -0300

ActionController::RoutingError (No route matches [GET] "/system/computer/cfotos_2_thumb_cfotos.jpg"):
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:incall'
railties (3.2.8) lib/rails/rack/logger.rb:26:in call_app' railties (3.2.8) lib/rails/rack/logger.rb:16:incall'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.1) lib/rack/methodoverride.rb:21:incall'
rack (1.4.1) lib/rack/runtime.rb:17:in call' activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:incall'
rack (1.4.1) lib/rack/lock.rb:15:in call' rack-cache (1.2) lib/rack/cache/context.rb:136:inforward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in fetch' rack-cache (1.2) lib/rack/cache/context.rb:185:inlookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in call!' rack-cache (1.2) lib/rack/cache/context.rb:51:incall'
railties (3.2.8) lib/rails/engine.rb:479:in call' railties (3.2.8) lib/rails/application.rb:223:incall'
rack (1.4.1) lib/rack/content_length.rb:14:in call' railties (3.2.8) lib/rails/rack/log_tailer.rb:17:incall'
thin (1.5.0) lib/thin/connection.rb:81:in block in pre_process' thin (1.5.0) lib/thin/connection.rb:79:incatch'
thin (1.5.0) lib/thin/connection.rb:79:in pre_process' thin (1.5.0) lib/thin/connection.rb:54:inprocess'
thin (1.5.0) lib/thin/connection.rb:39:in receive_data' eventmachine (1.0.0) lib/eventmachine.rb:187:inrun_machine'
eventmachine (1.0.0) lib/eventmachine.rb:187:in run' thin (1.5.0) lib/thin/backends/base.rb:63:instart'
thin (1.5.0) lib/thin/server.rb:159:in start' rack (1.4.1) lib/rack/handler/thin.rb:13:inrun'
rack (1.4.1) lib/rack/server.rb:265:in start' railties (3.2.8) lib/rails/commands/server.rb:70:instart'
railties (3.2.8) lib/rails/commands.rb:55:in block in <top (required)>' railties (3.2.8) lib/rails/commands.rb:50:intap'
railties (3.2.8) lib/rails/commands.rb:50:in <top (required)>' script/rails:6:inrequire'
script/rails:6:in `

'

My gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'pg', '0.13.2'
gem 'json'
gem 'rails_admin'

gem "paperclip", "~> 2.8"
gem "cancan", "1.6.8"

group :assets do
gem 'sass-rails', '> 3.2.3'
gem 'coffee-rails', '
> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end

group :production, :preview do
end

group :development, :test do
gem 'magic_encoding' # for create encoding UTF-8 hack to Ruby 1.9
gem 'thin'
gem 'silent-postgres'
end

gem 'jquery-rails'

Deploy with Capistrano

gem 'capistrano'

To use debugger

gem 'ruby-debug'

gem "devise"

My model

class Computer < ActiveRecord::Base

def full_name
"#{self.npatrimonio} (#{self.location.name if self.location})"
end

belongs_to :computertype
belongs_to :location
belongs_to :manufacturer
has_and_belongs_to_many :softwares

has_attached_file :cfoto,
:path => ":rails_root/public/system/computer/:attachment_:id_:style_:basename.:extension",
:url => "/system/computer/:attachment_:id_:style_:basename.:extension",
:styles => {
:thumb => {
:geometry => '100x75>',
:quality => 70,
:format => 'jpg' },
:original => {
:geometry => '700x700>',
:quality => 70,
:format => 'jpg' }
}

add a delete_<asset_name> method:

attr_accessor :delete_cfoto
before_validation { self.cfoto.clear if self.delete_cfoto == '1' }

accepts_nested_attributes_for :softwares#, :allow_destroy => true

attr_accessible :npatrimonio, :nserie, :departamento, :computertype_id, :location_id, :manufacturer_id, :software_ids, :cfoto, :delete_cfoto

end

kraudio commented Nov 21, 2012

Solution

in preview.rb/production.rb
config.serve_static_assets = true

@kraudio kraudio closed this Nov 21, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment