LoginSignup
0
0

More than 3 years have passed since last update.

【ruby on rails】Rails超入門0❗️RailsをRailsInstallerでwindows10にインストール

Posted at

0.Railsinstallerとの出会い

rails6.0インストール⇒失敗
rails5.0インストール⇒失敗
sqlite3とのバージョンが合わない、
webpackerのインストール、nodejsのインストール
・・・・・
何故かうまくいかないのだ。
環境ができないと試すこともできない。
そんな時に出会ったのがRailsInstallerだった。

1.RailsInstallerのダウンロードとインストール

1.画面に従ってインストールする。
ここから欲しいバージョンのものをダウンロードをする。

railsinstaller1.jpg

※railsinstaller:ruby on railsを構築する上で必要なソフトが入った
all in one packageのようなもの

私はrailsinstaller-3.4.0.exeを入手した。

2.コマンドプロンプトでruby.exeのあるフォルダに移動
c:\RailsInstaller>cd Ruby2.3.3

2.Railsアプリケーションの作成

(1)下記コマンドを入力する(rails_appはアプリケーション名)
c:\RailsInstaller\Ruby2.3.3>rails new rails_app

(2)bundlerを下記コマンドでインストールする。

c:\RailsInstaller\Ruby2.3.3\rails_app>gem install bundler
Fetching: bundler-2.1.4.gem (100%)
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Installing ri documentation for bundler-2.1.4
Done installing documentation for bundler after 25 seconds
1 gem installed

(3)c:\RailsInstaller\Ruby2.3.3\rails_app>rails server

Could not find gem 'uglifier (>= 1.3.0) x86-mingw32' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.

c:\RailsInstaller\Ruby2.3.3\rails_app>bundle install

(4)色々エラーが出てくるので
bundle installコマンドを入力する。

c:\RailsInstaller\Ruby2.3.3\rails_app>bundle install
(略)
An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.
Make sure that gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/'
succeeds before bundling.

In Gemfile:
sqlite3

(5)Gemfileの修正

sqlite3でエラーが出ている。
rails_app(アプリケーションフォルダ内)内のGemfileの下記部分を

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

下記のように1.3系に修正する

# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
gem 'sqlite3', '~> 1.3.13'

(6)bundle installコマンドを入力する。

Bundle complete! 13 Gemfile dependencies, 66 gems now installed.
Use bundle info [gemname] to see where a bundled gem is installed.

何もエラーが出なければ終了。

3.rails serverコマンドで接続を確認

c:\RailsInstaller\Ruby2.3.3\rails_app>rails server
=> Booting Puma
=> Rails 5.1.7 application starting in development
=> Run `rails server -h` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.12.4 (ruby 2.3.3-p222), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/" for ::1 at 2020-03-10 13:43:37 +0900
Processing by Rails::WelcomeController#index as HTML
Started GET "/" for ::1 at 2020-03-10 13:43:40 +0900
Processing by Rails::WelcomeController#index as HTML
  Rendering C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.7/lib/rails/templates/rails/welcome/index.html.erb
  Rendering C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.7/lib/rails/templates/rails/welcome/index.html.erb
  Rendered C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.7/lib/rails/templates/rails/welcome/index.html.erb (122.0ms)
  Rendered C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.7/lib/rails/templates/rails/welcome/index.html.erb (0.0ms)
Completed 200 OK in 4508ms (Views: 1335.9ms)

(2)http://localhost:3000/
で下記の画面が出たら成功

railsinstaller_server_ok.jpg

最後に

こうすると、楽にインストールできるよとか、
SQLiteだけでなく、他のdbも使えるとか教えて頂けると嬉しいです。

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