Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我跑步,rails generate controller ControllerName我会得到一个空控制器?我可以手动将其编辑为我想要的,但为什么会出现这种情况?如果我将选项留空,是否不应该将 7 默认值放在那里?
rails generate controller ControllerName
这是控制器生成器的默认行为。如果您想要默认操作,您将需要使用rails generate scaffold.
rails generate scaffold
请注意,您还可以将动作名称传递给控制器生成器以生成空白动作。这负责设置基本测试/视图/等,但您需要为您以这种方式定义的每个操作编写自己的代码:
rails generate controller ControllerName action1 action2 etc