Rails版本:5.0.0.1
Ruby版本:ruby 2.3.1p112(2016-04-26修订版54768)[x86_64-linux]
OS:Ubuntu 16.04.1 LTS xenial
我想用prawn gem生成pdf文件。我在gem文件中添加了prawn并运行了安装了prawn的bundle install。
执行'捆绑显示对虾'显示
/home/kapil/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/prawn-2.1.0
如果我查看Gemfile.lock,它会显示
pdf-core (0.6.1)
pg (0.18.4)
pkg-config (1.1.7)
prawn (2.1.0)
pdf-core (~> 0.6.1)
ttfunk (~> 1.4.0)
kapil@kapil-server1:~/apps/badal$ rails console
Running via Spring preloader in process 32445
Loading development environment (Rails 5.0.0.1)
irb(main):001:0> require "prawn"
LoadError: cannot load such file -- prawn
from /home/kapil/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/kapil/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /home/kapil/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/kapil/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from (irb):1
irb(main):013:0* Prawn::Document
NameError: uninitialized constant Prawn
from (irb):13
from /home/kapil/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in `start'
from /home/kapil/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in `start'
我的Gem文件如下:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
#Added by Kapil
gem 'bootstrap-sass', '~> 3.3.6'
gem 'simple_form'
gem 'momentjs-rails', '~> 2.9', :github => 'derekprior/momentjs-rails'
gem "jstree-rails-4"
gem "rails-erd"
gem "seedbank"
gem 'rack-mini-profiler'
gem 'bcrypt'
gem "select2-rails"
gem "bullet", :group => "development"
gem 'activerecord-session_store'
gem "prawn"
我不知道为什么虾会以这种方式表现?
答案 0 :(得分:-1)
我不是专家,但看起来你需要从头开始学习ruby。使用rails console
,您可以查看数据库中的内容,并且它与Gemfile无关。我建议从[Ruby on Rails Tutorial]开始。对不起,你应该做很多大虾。1