0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WindowsでRuby on Railsを動かす最初の一歩

0
Posted at

WSLのインストール

PowerShellを起動して、WSLをインストールします。

wsl --install

ディストリビューションを指定していませんが、上記でUbuntuがインストールされるようです。

依存パッケージのインストール

Ubuntuにログインした状態で以下のコマンドを実行します。

sudo apt update
sudo apt install build-essential rustc libssl-dev libyaml-dev zlib1g-dev libgmp-dev git

これで依存パッケージをインストールできます。

Rubyのバージョン管理ツールをインストール

引き続きUbuntuで以下のコマンドを実行します。

curl https://mise.run | sh
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
source ~/.bashrc
mise use -g ruby@3

これでRuby3系が使用されます。

ruby --version

Railsのインストール

Ubuntuで以下のコマンドを実行します。

gem install rails
rails --version

これでRailsがインストールされました。

Railsアプリの作成

Ubuntuで以下のコマンドを実行します。
例としてtask_appを作成します。

rails new task_app
cd task_app

Railsアプリの起動

Ubuntuで以下のコマンドを実行します。
DBを作成してサーバーを起動します。

bin/rails db:create
bin/rails server

ブラウザを開いて以下のURLにアクセスします。

http://localhost:3000

起動したサーバーはCtrl+Cで停止できます。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?