rails2 如何使用scaffold生成嵌套资源 nesting resource
2012-05-04 17:17
232 查看
如下代码可以生成嵌套resources,但是不是很好
使用gem 生成嵌套资源
https://github.com/chucai/NestedRestfulScaffold
原地址是
https://github.com/mahkhaled/NestedRestfulScaffold
安装
生成嵌套资源
eg:
生成的嵌套资源是
嵌套资源的URL前加api的方法是
会生成 /api/circles/1/activities 的地址
ruby script/generate scaffold post title:string doc:text ruby script/generate scaffold comment post:references doc:text Map.resources :posts :has_many=>:comments
使用gem 生成嵌套资源
https://github.com/chucai/NestedRestfulScaffold
原地址是
https://github.com/mahkhaled/NestedRestfulScaffold
安装
gem install nested_restful_scaffold
生成嵌套资源
script/generate nested_restful_scaffold ModelName [field:type, field:type, resource1,resource2,...:resources]
eg:
script/generate nested_restful_scaffold book name:string description:text library:references library:resources
生成的嵌套资源是
map.resources :libraries do |library| library.resources :books end
嵌套资源的URL前加api的方法是
map.with_options(:path_prefix => "/api") do |api| api.resources :circles do |circle| circle.resources :activities end end
会生成 /api/circles/1/activities 的地址
相关文章推荐
- Android生成工具包时如何使用图片资源
- 添加一个文件夹及一些文件如何使用git生成patch git补丁 新文件 图片资源文件
- 如何使用VC6编译sqlite3源码生成动态链接库(版本:sqlite-source-3_6_23_1)
- 如何使用curl进行验证码生成和验证
- 如何使用测试证书来生成越狱版的ipa包
- 添加一个文件夹及一些文件如何使用git生成patch
- 多模块Maven项目如何使用javadoc插件生成文档
- Spark Streaming性能优化系列-如何获得和持续使用足够的集群计算资源?
- 详解如何查看 docker 容器使用的资源
- [WinForm每日一帖] 如何使用资源文件提供Excel模板下载
- 如何引用第三方提供的.so库文件以及如何使用javah生成.h文件
- SQL Server中如何生成GUID C#.NET中如何生成和使用GUID
- 使用LabVIEW如何生成应用程序(exe)和安装程序(installer)
- 黄聪:在C#中如何使用资源中的图片
- 如何使用资源和样式调整控件外观
- 【网络安全】如何使用OpenSSL工具生成根证书与应用证书
- 如何查看使用最多内存资源的进程?
- 如何使用ResourceManger,及使用ResourceManager过程中出错的找不到资源的错误
- 如何使用ASP生成Word文件
- [置顶] 简述如何嵌套使用Viewpager,点击图片放大查看图片,并且使用PhotoView进行图片处理