Ruby on Rails生成视图 [英] Ruby on Rails Generating Views
问题描述
有没有一种方法可以使用rails generate命令分别生成视图?我也愿意安装一个gem来完成存在的任务.基本上,脚手架命令给了我太多,我宁愿手动编码我的控制器.但是,用记录表编写索引视图并不是很有效.
Is there a way to generate the views separately using the rails generate command? I would also be willing to install a gem to accomplish that task f one exists. Basically the scaffolding command gives me too much and I would rather code my controller by hand. However, writing the index view with a table for the records would not be very efficient.
推荐答案
您可以使用控制器生成器来生成控制器和视图.
You can generate the controller and the view using the controller generator.
rails g controller controllername new create
这将创建动作new
和create
及其相应的视图.
This will create actions new
and create
with their corresponding views.
您仍然需要以此手动设置路线.
You still need to set up your routes manually with this.
这篇关于Ruby on Rails生成视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!