LoginSignup
1
0

RubyOnRails: Turbo の使い方

Last updated at Posted at 2024-02-14

次のページを参考にしました。
サンプルアプリケーションを作成する

確認した環境

$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux-gnu]

$ rails --version
Rails 7.1.3

$ bundle --version
Bundler version 2.5.6

必要な Gem のインストール

sudo gem install turbo-rails

プロジェクトの作成

rails new sample_aa
cd sample_aa
bundle install
rails generate scaffold Book title:string
rails db:migrate

サーバーの起動

rails server -b 0.0.0.0

ブラウザーでデータを入れた状況
image.png

データベースの確認

$ sqlite3 storage/development.sqlite3
SQLite version 3.40.1 2022-12-28 14:03:47
Enter ".help" for usage hints.

sqlite> .table
ar_internal_metadata  books                 schema_migrations   

sqlite> select * from books;
1|いばらひめ|2024-02-14 00:09:20.511030|2024-02-14 00:09:20.511030
2|赤ずきん|2024-02-14 00:09:39.345029|2024-02-14 00:09:39.345029
3|おいしいおかゆ|2024-02-14 00:09:50.736723|2024-02-14 00:09:50.736723
4|星の銀貨|2024-02-14 00:09:59.033606|2024-02-14 00:09:59.033606
sqlite>

エラー対策

rails new sample_aa
で次のようなエラーが出る時の対策

Could not find net-imap-0.4.10, net-pop-0.1.2, net-smtp-0.4.0.1,
bigdecimal-3.1.6, drb-2.2.0, mutex_m-0.2.0, rake-13.1.0, rdoc-6.6.2,
io-console-0.7.2, date-3.3.4, net-protocol-0.2.2, psych-5.1.2, stringio-3.1.0 in
locally installed gems
sudo gem install sprockets-rails sqlite3 puma
sudo gem install importmap-rails stimulus-rails jbuilder bootsnap debug
sudo gem install web-console error_highlight capybara selenium-webdriver
sudo gem install bindex addressable regexp_parser xpath base64 rexml
sudo gem install net-imap net-pop net-smtp bigdecimal drb mutex_m rake
sudo gem install rdoc io-console date net-protocol psych stringio
1
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
1
0