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?

More than 5 years have passed since last update.

Ruby on Rails のMVCモデル

0
Last updated at Posted at 2019-11-11

MVCモデル

 この記事では、Ruby on Railsを用いたアプリケーション開発のアーキテクチャパターンである、MVCモデルについて説明する。
 自分が作成したRailsアプリのアプリ構造において、appディレクトリ下にはmodels,views,controllersという3つのサブディレクトリがあり、これらがMVCモデルの中心的要素となる。

image.png

上図はMVCモデルの概念図であり、models,views,controllersそれぞれの役割は、
View:HTMLファイルを生成
Controller:ブラウザからwebサーバに渡されたリクエストをルーティングに基づいて処理し、静的なコンテンツの場合はViewを通してすぐにブラウザにHTMlを表示し、動的なコンテンツの際は、データベースとの通信を担当しているRubyのオブジェクトであるモデルを介してリクエストに基づくHTMLをブラウザに返す。
Model:Controllerの説明のように、コントローラーのアクションからの命令に従いデータベースから適切なデータを取得する
である。

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?