Sea*_*ean 41 views ruby-on-rails models scaffold
我已经获得了一个具有控制器(仅限最少代码)和模型的项目,但缺少视图.有没有办法只使用脚手架或其他工具生成视图?
Dav*_*ton 80
rails g scaffold User --migration=false --skip
Run Code Online (Sandbox Code Playgroud)
--skip
跳过已存在文件的方法.(相反的是--force
.)
如果你不想要帮助者,--helpers=false
.
删除我的User
观看后的示例输出:
invoke active_record
identical app/models/user.rb
invoke test_unit
identical test/unit/user_test.rb
skip test/fixtures/users.yml
route resources :users
invoke scaffold_controller
identical app/controllers/users_controller.rb
invoke erb
exist app/views/users
create app/views/users/index.html.erb
create app/views/users/edit.html.erb
create app/views/users/show.html.erb
create app/views/users/new.html.erb
create app/views/users/_form.html.erb
invoke test_unit
identical test/functional/users_controller_test.rb
invoke helper
identical app/helpers/users_helper.rb
invoke test_unit
identical test/unit/helpers/users_helper_test.rb
invoke assets
invoke coffee
identical app/assets/javascripts/users.js.coffee
invoke scss
identical app/assets/stylesheets/users.css.scss
invoke scss
identical app/assets/stylesheets/scaffolds.css.scss
Run Code Online (Sandbox Code Playgroud)
Ric*_*ith 15
这是脚手架生成器内部调用的内容:
rails g erb:scaffold User
Run Code Online (Sandbox Code Playgroud)
erb
是使用的模板引擎,所以你也可以使用haml:scaffold
.
你必须明确指定的字段,你想脚手架使用-轨道并不会自动从创建的模型推导出它们.例如:
rails g erb:scaffold User firstname lastname reputation
Run Code Online (Sandbox Code Playgroud)
请参阅rails g --help
跳过,强制覆盖和干运行或generate scaffold --help
有关生成脚手架的信息等选项.
归档时间: |
|
查看次数: |
25112 次 |
最近记录: |