LoginSignup
0
0

More than 1 year has passed since last update.

Yay! You’re on Rails!から画面が変わらない

Posted at

はじめに

スクリーンショット 2021-06-28 19.24.54(2).png

railsを立ち上げるといつものように僕たちを迎え入れてくれます!

これから作っていくぞって時に初歩的なミスをしたので残しておきます。

アプリケーション作成

% rails _6.0.0_ new app -d mysql  

コントローラー作成

% rails g controller tweets 

モデル作成

% rails g model tweet

大枠ができたのでフロント部分でツイートの表示ができるようにindex.html.erbを作成し、記述を始めました。
うまく表示できているか確認すると・・・

スクリーンショット 2021-06-28 19.24.54(2).png

もうわかったよ〜涙

ここで私は初歩的なミスをした事に気付きました。

ルーティング書いてない!

routes.rb
Rails.application.routes.draw do
  root to: "tweets#index"
end

ここで初めて画面が変わります。

こうする事によって、「 http://localhost:3000/ 」が呼び出された時に"tweets#index"の内容が画面上に映し出されます。

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