Rails 4 - 推进Heroku问题

时间:2014-12-22 06:31:35

标签: ruby-on-rails git heroku

谢谢你看@这个。我相信这是一个相对简单的问题。有点长的帖子,所以你们都有任何关于我的设置和推送到Heroku的信息。 我正在遵循本指南。 http://docs.railsbridge.org/intro-to-rails/deploying_to_heroku

我有这个错误:

To git@heroku.com:polar-thicket-3762.git                                                                                        
 ! [remote rejected] master -> master (pre-receive hook declined)                                                               
error: failed to push some refs to 'git@heroku.com:polar-thicket-3762.git'

当我尝试推送到Heroku时会发生这种情况。它试图预编译资产。 解决方案说我需要在我的application.rb中添加这一行,以便成功推送我尝试过的。

ruby config.assets.initialize_on_precompile = false

它确实成功推动,但随后它不会通过

编译数据库
heroku run rake db:migrate

然后,当我尝试运行该命令时,它说它不会运行rake db:migrate on thread .3309,因为" ruby​​"没找到。我试着去除它前面的红宝石,然后它就不会推到heroku。

如何通过推送到Heroku来解决这个问题,并让它来编译数据库? 谢谢!

了解一些事情会很有帮助,我使用Nitrous.io和Sqlite3进行开发。 我的application.rb是这样的(并且下面还列出了database.yml& gemfile)

application.rb中

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module RailsBase
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    # To push to Heroku 
    config.assets.initialize_on_precompile = false
  end
end

DATABASE.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:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# 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:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  <<: *default
  database: db/production.sqlite3

GEMFILE ---------------------------------------------- ------------

source 'https://rubygems.org'

ruby "2.0.0"

gem 'rails', '4.1.6'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
gem 'jquery-rails'
gem 'bootstrap-sass', '~> 3.2'
gem 'puma'
gem 'thin'
gem 'bcrypt'

gem 'rmagick'
gem 'carrierwave'                   #to handle image uploads

# Push to heroku
# Look @ this site below for more instructions and look @ section "each time"
# http://docs.railsbridge.org/intro-to-rails/deploying_to_heroku

group :development, :test do
  gem 'byebug'
  gem 'sqlite3'
end

# Add for Heroku deployment to "production" which in my case is stage
group :production do
  gem 'pg'
  gem 'rails_12factor'
end


# Use Uglifier as compressor for JavaScript assets
# gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
# gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby


# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

# 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

# Use debugger
# gem 'debugger', group: [:development, :test]

1 个答案:

答案 0 :(得分:1)

确保您的rails应用程序位于repo的根目录中,Gemfile存在且已正确命名。它基本上无法将您的代码库检测为受支持的项目类型之一,因此失败了。此外,即使你有一个合适的项目,确保它是回购的一部分,你已经做好了(git status将帮助你在这里,并且ls应该帮助你验证项目结构)