从Ruby on Rails 4.2.7.1升级到5.0.1 - 仍尝试使用railties 4.2.7.1

时间:2017-01-25 17:06:43

标签: ruby-on-rails ruby upgrade ruby-on-rails-5 rails-4-upgrade

我正在创建一个网站,但意外安装了Ruby on Rails版本4而不是版本5,并且想要升级到最新版本,以便使用我所拥有的版本中目前缺少的一些功能我的系统。

我尝试过遵循本指南:

http://railsapps.github.io/updating-rails.html

我安装了rvm并按顺序运行了所有预赛,直到本节:

rvm use ruby-2.3.1@rails5.0 --create
gem install rails
rails -v

我遇到问题的地方。 rvm use ruby-2.3.1@rails5.0 --create输出:

ruby-2.3.1 - #gemset created /home/dev/.rvm/gems/ruby-2.3.1@rails5.0
ruby-2.3.1 - #generating rails5.0 wrappers..........
Using /home/dev/.rvm/gems/ruby-2.3.1 with gemset rails5.0

精细。 Gem install rails也会毫无错误地进行,安装所有36个宝石,其中包括:

Fetching: rails-5.0.1.gem (100%)
Successfully installed rails-5.0.1

Fetching: railties-5.0.1.gem (100%)
Successfully installed railties-5.0.1

然而,当我之后直接运行rails -v时,我得到:

Could not find proper version of railties (4.2.7.1) in any of the sources  
Run `bundle install` to install missing gems.

但是,当我运行bundle install时,系统将恢复为rails 4.2.7.1。

我是否需要做一些额外的事情来安装/链接/任何铁路4.2.7.1,并停止系统恢复到原始版本的rails?我不太使用rails,所以我对配置并不是特别熟悉。也许我需要在我的应用程序中更改配置文件?

1 个答案:

答案 0 :(得分:3)

问题出在Gemfile中,其中包含旧版本号。我更新到以下内容:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.0.1'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.13', '< 0.5'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.6'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 3.0.4'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2.1'
# 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.4.1'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.1', group: :doc

# 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

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
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

然后运行bundle update后跟bundle install,现在有了Rails 5.0.1。感谢Iceman建议查看Gemfile!