Is there a way to generate a subset of methods in the controller using scaffold instead of the regular scaffold?
有没有办法使用脚手架而不是常规脚手架在控制器中生成方法的子集?
For example: Only create new and show?
例如:只创建新的和显示?
I am using rails 3, ruby 1.9.2
我使用rails 3,ruby 1.9.2
Thanks
2 个解决方案
#1
2
I do not think the default rails scaffold generator supports this in Rails 3.
我不认为默认的rails scaffold生成器在Rails 3中支持这一点。
However, this can be accomplished using the nifty-generators gem:
但是,这可以使用nifty-generator gem来完成:
#2
1
In plain Rails3, you can do this when you generate the controller:
在普通的Rails3中,您可以在生成控制器时执行此操作:
rails generate controller Artists new create
So, you could just generate the model, and then the controller, and get the overall functionality you were looking for.
因此,您可以生成模型,然后生成控制器,并获得您正在寻找的整体功能。
#1
2
I do not think the default rails scaffold generator supports this in Rails 3.
我不认为默认的rails scaffold生成器在Rails 3中支持这一点。
However, this can be accomplished using the nifty-generators gem:
但是,这可以使用nifty-generator gem来完成:
#2
1
In plain Rails3, you can do this when you generate the controller:
在普通的Rails3中,您可以在生成控制器时执行此操作:
rails generate controller Artists new create
So, you could just generate the model, and then the controller, and get the overall functionality you were looking for.
因此,您可以生成模型,然后生成控制器,并获得您正在寻找的整体功能。