开发者

script/generate scaffold against specific database?

I'm wondering if there is a way to generate scaffolding against a specific database. I am using two databases in my app and would like to generate scaffolding for both, separately. This is assuming th开发者_JAVA技巧at the scaffold generator still uses the database to generate views in rails 2.3.4, which may not be the case.

Thanks in advance.


I haven't test it, but would this work?

RAILS_ENV=test script/generate scaffold Whatever


You define the fields for the resource when running the scaffold, this will generate the views, model, controller, tests and the migrate file (which is then used to create the database table).

For example: rails generate scaffold Post name:string title:string content:text

Scaffold works in reverse of what you seem to be trying to achieve.

http://guides.rubyonrails.org/getting_started.html#creating-a-resource

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜