【问题标题】:How do you generate views/controllers/tests given the model给定模型,如何生成视图/控制器/测试
【发布时间】:2012-01-15 16:49:33
【问题描述】:

如何为一个全新的 Rails 3.x 应用程序生成视图/控制器/测试,该应用程序在 app/models 下具有所有相关模型类。

【问题讨论】:

标签: ruby-on-rails ruby-on-rails-3


【解决方案1】:

在控制台输入

rails generate controller <controller name> <action1> <action2> <etc..>

例如

rails generate controller items new create edit update destroy index show

这会在 app/controllers 中生成 items_controller.rb、new.html.erb、edit.html.erb 和 app/views 中的其他操作以及 test/ 中的测试模板

【讨论】:

    猜你喜欢
    • 2011-05-20
    • 1970-01-01
    • 2015-11-07
    • 1970-01-01
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    相关资源
    最近更新 更多