2014-02-07 73 views
-1

我遇到了在生產中運行對象的問題。Ruby on Rails應用程序中的對象,生產失敗

我跟着Railscast(修訂版http://railscasts.com/episodes/153-pdfs-with-prawn-revised?view=asciicast)寫了封信。它適用於我的開發環境(Mac OS X 10.9.1),但會導致獨角獸在我的服務器上徘徊不前。我的生產服務器是(紅帽=>紅帽企業Linux服務器版本6.4(聖地亞哥))。我通過Gemfile安裝了gem。

的Gemfile:

gem 'prawn' 
    gem 'prawn-qrcode' 

控制器:(show行爲)

def show 
     #@classroom = Classroom.find(params[:id]) 
     @classroom = find_classroom 

     @page_title = @classroom.location.name 
     @classroom_alt = @classroom.location.name + " - " + @classroom.room_number 
     @building = find_building(@classroom.location_id) 
     @owner = Owner.find(@classroom.owner_id) 
     @room_schedule_contact = RoomScheduleContact.find_by rmrecnbr:(@classroom.rmrecnbr) 
     @building_image = @building.picture.url(:medium).to_s 
     @building_sign_image = @building.building_sign.url(:thumb).to_s 
     @search = Classroom.search(params[:search]) 

     #@classroom_herprod = Building.find(params[:location_id]).building_short_code 
     respond_to do |format| 
     format.html # show.html.erb 
     format.png { render :qrcode => "http://rooms.lsa.umich.edu/classrooms/#{@classroom.facility_code_heprod}", :level => :l, :unit => 8 } 
     format.pdf do 
     pdf = ClassroomPdf.new(@classroom) 

      send_data pdf.render, type: "application/pdf", 
           disposition: "inline" 
     end 
     end 
    end 

我有包含以下內容的classroom_pdf.rb文件中的PDF文件的目錄。 (這是從我所有的,但它是最基本的版本,在我的開發系統工作,並在生產失敗)。

我運行以下

紅寶石2.1.0p0(2013年12月25日修訂44422)x86_64的Linux的] 寶石 '軌道', '4.0.2'

的錯誤unicorn.stderr.log如下。

 E, [2014-02-07T12:39:20.400750 #7300] ERROR -- : reaped #<Process::Status: pid 7306 exit 1> worker=1 
    I, [2014-02-07T12:39:20.401257 #7300] INFO -- : worker=1 spawning... 
    I, [2014-02-07T12:39:20.463964 #7529] INFO -- : worker=1 spawned pid=7529 
    I, [2014-02-07T12:39:20.521524 #7529] INFO -- : Refreshing Gem list 
    E, [2014-02-07T12:39:29.938423 #7326] ERROR -- : uninitialized constant Prawn (NameError) 
     /var/www/rooms.lsa.umich.edu/html/iris/releases/20140207173433/app/pdfs/classroom_pdf.rb:1:in `<top (required)>' 
    /var/www/rooms.lsa.umich.edu/html/iris/shared/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!' 

這裏是Gemfile中

source 'https://rubygems.org' 
    ##gem 'rails', '3.2.14' 
    gem 'rails', '4.0.2' 
    gem 'sqlite3' 
    gem 'sass-rails', '~> 4.0.0' 
    gem 'uglifier', '>= 1.3.0' 
    gem 'coffee-rails', '~> 4.0.0' 
    #gem 'jquery-rails' 

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

    gem "haml" 
    #gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails' 
    gem 'bootstrap-sass', '~> 3.1.0' 

    #gem 'google-analytics-rails' 

    gem 'font-awesome-rails' 

    gem 'protected_attributes' 
    gem 'modernizr-rails' 
    gem "jquery-rails" 
    gem "devise", "3.0.3" 
    gem "cancan", ">= 1.6.9" 
    gem "rolify", ">= 3.2.0" 
    gem 'newrelic_rpm' 

    # QR-Code generation 
    gem 'rqrcode-rails3' 
    gem 'mini_magick' 

    gem 'prawn' 
    #gem 'prawn', '1.0.0.rc2' 
    gem 'prawn-qrcode' 
    #gem 'prawnto' 

    gem 'capistrano', '2.15.5' 
    #gem 'capistrano' 
    gem "simple_form" 
    gem 'will_paginate', '~> 3.0.5' 
    gem "therubyracer", :group => :assets, :platform => :ruby 
    gem 'will_paginate-bootstrap' 
    #gem 'kaminari' 

    ## Used for uploading and resizing images (Need both paperclip and mini_magick) 

    gem "paperclip", "3.5.1" 

    #gem "meta_search" 
    gem "ransack" 
    gem 'annotate', ">=2.6.0" 

    group :production do 
     gem 'unicorn' 
    end 

任何想法?

+0

請顯示您的gemfile嗎? – uday

+0

你確定gem在prod服務器上正確安裝嗎? –

+0

當我導航到項目(當前版本)目錄並檢查Gemfile.lock大蝦是否存在。我還能做另一張支票嗎? – humbledaisy

回答

0

事實證明,我需要手動重新啓動獨角獸才能正確加載新的gem文件。