Версия Ruby: 2.0.0p195 Rails: 4.2.0beta4
Поэтому я попытался запустить rake assets:precompile. (Звучит как хорошая идея) И я получаю следующую трассировку:
rake aborted!
LoadError: cannot load such file -- sqlite3/database
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.10-x86-mingw32/
lib/sqlite3.rb:9:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.10-x86-mingw32/
lib/sqlite3.rb:9:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:72:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:72:in `block (2 levels) in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:70:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:70:in `block in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:59:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:59:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.r
b:132:in `require'
C:/2/heroku2/config/application.rb:7:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:4
5:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:4
5:in `require'
C:/2/heroku2/Rakefile:4:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_m
odule.rb:28:in `load'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_m
odule.rb:28:in `load_rakefile'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:689:in `raw_load_rakefile'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:94:in `block in load_rakefile'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:176:in `standard_exception_handling'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:93:in `load_rakefile'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:77:in `block in run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:176:in `standard_exception_handling'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:75:in `run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/bin/rake:33:in
`<top (required)>'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `load'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `<main>'
Мой гемфайл:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0.beta4'
# Use sqlite3 as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0.beta1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jQuery as the JavaScript library
gem 'jquery-rails', '~> 4.0.0.beta2'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
group :production do
gem 'pg'
gem 'rails_12factor'
end
# 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'
gem 'pry'
gem 'sqlite3', '1.3.10'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0.0.beta4'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
gem 'arel', '6.0.0.beta2'
gem 'devise'
gem 'paperclip', '~> 4.1'
gem 'seems_rateable'
Я изучаю Ruby on Rails, поэтому предположим, что я упускаю очевидное.
РЕДАКТИРОВАТЬ:
Вы правы trueinViso - я не указал postgres в database.yml. Что я должен написать? Это база данных.yml:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
2 ответа
Что я сделал: я изменил базу данных разработки, чтобы использовать postgres 'pg'gem. (Что, вероятно, бесполезно. На самом деле я не знаю, актуально ли это).
Самое главное, проделав вышеописанное, я изменил database.yml на (адаптер был неправильный "postgresl":
development:
adapter: postgresql
host: localhost
database: pqqq
username: pqqqq
password: pqqqq
test:
adapter: postgresql
encoding: unicode
database: testdb_pow
pool: 5
username: parseb
password: testtt
Затем я запустил rake asstes:precompile, а затем git push heroku master, и это сработало. (Не забудьте перенести базу данных на героку — героку запустите db:migrate.)
Вам не нужно было запускать rake assets:precompile
.
Просто перейдите к config/production.rb
и установите serve_static_assets = true
.
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = true
Когда вы снова нажмете на героку, активы будут работать. Это было решением для меня.
Похожие вопросы
Новые вопросы
ruby-on-rails
Ruby on Rails - это полнофункциональная платформа веб-приложений с открытым исходным кодом, написанная на Ruby. Он следует популярной модели фреймворка MVC и известен своим подходом «соглашение поверх конфигурации» при разработке приложений.