Ruby on Rails plural (controller) and singular (model) convention - explanation

前端 未结 5 1591
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 12:31

As per Ruby on Rails convention, controller names get pluralized while model names are singular. Example : a Users controller, but a User model.

rails genera         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 13:00

    An instance of your User model represents a single user, so is singular. The users table, by contrast, holds all of your users, so it's plural.

提交回复
热议问题