我正在try 部署一个基本的应用程序,但它不起作用.使用

git push heroku master 

我收到了这个错误信息:

remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     rake aborted!
remote:  !     LoadError: cannot load such file -- /tmp/build_a1cfcabff50107f84830d908386197b2/config/application
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/Rakefile:4:in `require'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/Rakefile:4:in `<top (required)>'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
remote:  !     vendor/bundle/bin/rake:16:in `load'
remote:  !     vendor/bundle/bin/rake:16:in `<main>'
remote:  !
remote: /app/tmp/buildpacks/ruby/lib/language_pack/helpers/rake_runner.rb:102:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)

bundle exec rake -P 似乎很好用.

我的文件没有什么特别之处,我只是添加了 bootstrap :

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'

# 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.1.0'
# 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 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

gem 'bootstrap-sass' 
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
#postgreeSQL for Heroku deployment


group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
  gem 'sqlite3'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'


  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end
group :production do
  gem 'pg'
  gem 'rails_12factor'
end
ruby "2.2.3"

我不明白为什么会这样,因为我有另一个正常工作的项目.我判断了所有东西,它仍然给我这个信息.

推荐答案

有时,Heroku会在部署assets资源 时抛出一个问题.您可以预编译assets资源 并将其推送到Heroku.

RAILS_ENV=production bundle exec rake assets:precompile

Update:

如果它不起作用,请确保添加

将其设置为enabledtrueanything:)

因为在Rails<;5.1 production.rb

config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

Heroku: App -> Settings -> "Reveal Config Vars"

Sample:

Ruby-on-rails相关问答推荐

带有data-turbo的rails`link_to‘未获得turbo_stream请求格式

如何判断字符串中是否包含列值

在Ruby中按特定值合并时,将两个对象数组添加到一起

Grape api (rails) - 未初始化常量 Endpoints::TodoAPI (NameError)

rspec中日期时间结束时的分数是多少?

Selenium chromedriver:无法从不可键入的键构造KeyEvent

heroku 推送错误:无法检测到 rake 任务

Rails 3 的data-method='delete'如何优雅地降级?

Ruby 地理定位Ruby /插件

rails s和bundle exec rails s有什么区别?

使用回形针进行简单裁剪

Gem 更新:在从 ASCII-8BIT 到 UTF-8 到 US-ASCII 的转换中,无法将 "\xE7" 转换为 UTF-8

Rails Mailer Net::OpenTimeout: execution expired 仅在生产服务器上出现异常

在 Ruby on Rails 上,我们如何在控制器中打印调试信息?

在 Rails 生产中禁用assets资源 缩小

Rails Associations - has_many => :through - 但相同的模型

Rails HABTM - 正确删除关联

Active Record has_many:通过删除一条关联记录

:javascript haml 标签中的内联Ruby ?

如何更改 Rails 3 控制器中视图文件的默认路径?