2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Railsプロジェクトを新規作成する

2
Posted at

rails new する機会ってあんまりないと思うし、その都度ググって調べるのもめんどくさいので、新規でrailsプロジェクトを作成する最低限おn手順を書き残す。

  • Ubuntu 18.04
  • rubyはインストールしてある前提(ここもいつも忘れるので記事書こうかな)

プロジェクトディレクトリを作成し移動

mkdir rails-project
cd rails-project

Gemfileの作成

bundle init

Gemfileの編集

こんな内容のGemfileが作成されるので、railsのversionを編集する。

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"
gem "rails", "5.2.3"  # railsのversionを指定

Gemをinstall

bundle install --path vendor/bundle
  • path オプションでinstall先を指定可能
  • rootディレクトリに、.bundle/config ファイルができ、ここにインストール先のpathが設定される。以降は、bundle install で指定したpathにGemがinstallされる。

Railsアプリケーションの新規作成

bundle exec rails new .
  • 「.」で、current directoryにRailsプロジェクトを新規作成する
  • `sqlite3` 関連のエラーが出るときは、下記を試してみる
sudo apt install libsqlite3-dev
bundle install

起動してみる

bundle exec rails s

Screenshot from 2019-04-30 23-39-51.png

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?