2

我是一名 ruby​​、ruby on rails 和 heroku 新手,正在尝试从Michael Hartl 的 Ruby on Rails 3.2 教程中学习编码。

现在在本章的开头,我未能将所有内容部署到 Heroku。我收到此错误消息(但我没有计划如何解决此问题):

$ git push heroku master
Counting objects: 69, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (54/54), done.
Writing objects: 100% (69/69), 27.34 KiB, done.
Total 69 (delta 5), reused 0 (delta 0)

-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.rc
       Running: bundle install --without development:test --path vendor/bundle --binstubs bin/
       Fetching gem metadata from https://rubygems.org/........
       Bundler could not find compatible versions for gem "railties": 
       In Gemfile: 
       rails (= 3.2.6) ruby depends on 
       railties (= 3.2.6) ruby 
       jquery-rails (= 2.0.0) ruby depends on 
       railties (3.2.7.rc1) 

 !
 !     Failed to install gems via Bundler.
 !
 !     Heroku push rejected, failed to compile Ruby/rails app

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

我的 Gemfile 看起来像这样:

source 'https://rubygems.org'

gem 'rails', '3.2.6'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0' 
end



# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.4'
  gem 'coffee-rails', '3.2.2'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.0'

group :test do
  gem 'capybara', '1.1.2'
end

group :production do
  gem 'pg', '0.12.2'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

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

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

我希望有人可以帮助我(对不起,我是初学者-->也在 Stackoverflow,哈哈)。KR,费边

4

3 回答 3

3

默认生成的 Gemfile(使用 rails 3.2.6)没有指定要使用的 jquery-rails 版本。我建议您也这样做,如下所示:

# remove version number, just like you would see in a fresh rails app
gem 'jquery-rails' 

您需要的版本 2.0.0 依赖于 railties 3.2.7.rc1 gem,您不能将其与 rails 3.2.6 一起使用。

我在我的应用程序中使用了您的代码,但无法将其捆绑在我的本地主机上。这让我想知道你在推到heroku之前是否也尝试过。您应该始终首先在本地计算机上捆绑安装。

此外,您似乎已经增加了 sass-rails 和 coffee-rails 所需的版本号。这是您在干净的 Rails 应用程序的 Gemfile 中所期望的:

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
于 2012-07-26T12:25:10.417 回答
1

我现在可以自己解决问题了。这是这样的:

  1. 转到 Gemfile 并将部分更改gem 'rails', '3.2.6'gem 'rails', '3.2.7rc1'
  2. 节省
  3. bundle install --without production
  4. git add .
  5. 像 git 一样提交git commit -a -m "Heroku recommit
  6. 像推送到githubgit push并按照用户名和密码的说明进行操作
  7. 最后git push heroku master

哇,这很难,但很有教育意义:-)

于 2012-07-26T12:33:13.640 回答
0

问题是 jquery-rails gem 需要与 bundle 文件中的 rails gem 不同版本的 railties。您可以尝试从 jquery-rails 中删除“2.0.0”,然后重试。Bundle 将安装一个适用于 3.2.6 版 railties 的 gem 版本。

于 2012-07-26T12:25:57.663 回答