我想使用 github/rails/rails 上提供的最新 rails 版本重建我的一个旧 rails 应用程序
我如何从"轨道新...."开始?
这似乎可以像这样简单:
$ mkdir example
$ cd example
$ echo "source 'https://rubygems.org'" >> Gemfile
$ echo "gem 'rails', git: 'https://github.com/rails/rails.git'" >> Gemfile
$ bundle install
Fetching https://github.com/rails/rails.git
Fetching gem metadata from https://rubygems.org/.............
Resolving dependencies...
Using rake 12.3.1
$ bundle exec rails new . --dev --force
exist
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
force Gemfile
run git init from "."
$ bundle exec rails server -d
=> Booting Puma
=> Rails 6.0.0.alpha application starting in development
=> Run `rails server --help` for more startup options
更新(2020(: 事实证明,稳定分支几乎拥有 HEAD 中发现的所有好东西,但实际上可以在生产中使用。因此,从那时起,我修改了解决方案,现在我使用以下步骤:
##
# Install edge rails
#
cd /tmp
git clone -b 6-0-stable --single-branch https://github.com/rails/rails
cd /tmp/rails
LATEST_COMMIT=$(git rev-parse --short HEAD)
bundle update --bundler
bundle install
cd /tmp/rails/railties/exe
bundle exec rails --version
bundle exec rails new /tmp/your-app-name --dev --database=postgresql --force
cd /tmp/your-app-name
bundle exec rails --version # verify
# Without this, you'll get the error: The path does not exist.
cd /tmp/your-app-name
s1='gem .rails.,.*'
s2="gem 'rails', git: 'https://github.com/rails/rails.git', ref: '$LATEST_COMMIT'"
perl -pi.bak -e "s/$s1/$s2/" Gemfile
bundle install
在目录中安装 rails 6(根据最新更新为 6.0.0(gem install rails -v 6.0.0
. 之后,您可以运行gem list rails
来检查已安装的 rails 版本。
您应该看到如下所示的内容
rails (6.0.0)
或rails (6.0.0, 5.2.3, 5.2.2)
如果您安装了多个版本。
现在通过以下方式创建新应用
rails _6.0.0_ new newapp
编辑: 在您关注之前,请查看@Rajan Verma的评论
截至目前可用的最新版本的导轨是6.1.0.alpha
.您可以像这样启动新应用程序:
rails new MyApp --skip-bundle
然后转到 宝石文件 并更改:
gem 'rails', '~> 5.2.3' # or whatever version you have
自:
gem 'rails', github: 'rails/rails'
或者,如果您想从最新的稳定版本开始,(截至目前(将其更改为:
gem 'rails', '~> 6.0.0.rc1'
然后运行bundle install
在这里,您可以找到有关最新版本的更多详细信息。