在已经创建控制器和模型之后创建 Ruby on Rails 视图(仅) [英] Create Ruby on Rails views (only) after controllers and models are already created
本文介绍了在已经创建控制器和模型之后创建 Ruby on Rails 视图(仅)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经获得了一个具有控制器(仅限最少代码)和模型的项目,但缺少视图.有没有办法只使用脚手架或其他工具生成视图?
I've obtained a project that have controllers (minimal code only) and models, but the views are missing. Is there a way to generate the views only using scaffold or another tool?
推荐答案
rails g scaffold User --migration=false --skip
--skip
表示跳过已经存在的文件.(相反的是--force
.)
The --skip
means to skip files that already exist. (The opposite is --force
.)
如果你不需要助手,--helpers=false
.
删除我的 User
视图后的示例输出:
Sample output after deleting my User
views:
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
这篇关于在已经创建控制器和模型之后创建 Ruby on Rails 视图(仅)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文