LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 5 years have passed since last update.

大学生管理アプリの作成8(Railsでscaffoldを使おう)

Last updated at Posted at 2019-05-21
rails generate scaffold Subject name:string
rails generate scaffold Student name:string subject:references email:string gender:integer age:integer opinion:text
rails generate scaffold Club name:string
rails generate scaffold ExamResult student:references name:string score:integer
rails generate scaffold ClubStudent student:references club:references

Railsで作成したデータベースのモデル情報をMySQLに反映させます。

rails db:migrate

MySQLにテーブルが出来ていることを確認します。

mysql -uroot -ppass1 cebu_college_development -e "show tables"

+------------------------------------+
| Tables_in_cebu_college_development |
+------------------------------------+
| ar_internal_metadata |
| club_students |
| clubs |
| exam_results |
| schema_migrations |
| students |
| subjects |
+------------------------------------+

Railsサーバーを起動させます。

rails s -b 0.0.0.0

ブラウザからアクセスすると、Railsアプリの雛形を見ることができます。

http://192.168.33.10:3000/students

スクリーンショット 2019-05-21 15.23.46.png

http://192.168.33.10:3000/students/new

スクリーンショット 2019-05-21 15.23.56.png

大学生管理アプリの作成9

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