When to create a new controller in rails

前端 未结 4 788
渐次进展
渐次进展 2020-12-15 03:23

I\'m wondering when you know that you need to create a controller in a rails application.

For example, I\'m going through the tutorial in Agile Web Development with

4条回答
  •  Happy的楠姐
    2020-12-15 04:10

    I am also new to RoR and I am doing a tutorial from Michael Hartl. I found in my research and in talking with more seasoned Rubyist that when you need the help of your Model (database) you should create a Controller. For example, if you are creating a session and the method that you are creating is going to need interfacing with the Model (database) by using, storing, updating, adding (a.k.a. RESTful behavior) then you will need a controller.

    Why? As stated before: the MVC frame work requires that Controllers be the only element that can interact with the Models (kinda like a bouncer at the V.I.P.section of a night club filled with hot women! The geeks are represented by "the view" LOL!!)!!

提交回复
热议问题