2011-11-03 5 views

答えて

2

Usage: 
    rails generate scaffold NAME [field:type field:type] [options] 

Options: 
    ... 

ActiveRecord options: 
    ... 

Rspec options: 
    [--singleton]     # Supply to create a singleton controller 
ユーザーは唯一つのポストを持っている場合は容易があると言うことのようにコマンドを実行することでした rails g scaffold Post name:string body:text --singleton

出力は、だから、足場は、通常のビューテンプレートを生成しているようです

invoke active_record 
    create db/migrate/20111103072825_create_posts.rb 
    create app/models/post.rb 
    invoke rspec 
    create  spec/models/post_spec.rb 
    route resources :posts 
    invoke scaffold_controller 
    create app/controllers/posts_controller.rb 
    invoke haml 
    create  app/views/posts 
    create  app/views/posts/index.html.haml 
    create  app/views/posts/edit.html.haml 
    create  app/views/posts/show.html.haml 
    create  app/views/posts/new.html.haml 
    create  app/views/posts/_form.html.haml 
    invoke rspec 
    create  spec/controllers/posts_controller_spec.rb 
    create  spec/views/posts/edit.html.haml_spec.rb 
    create  spec/views/posts/new.html.haml_spec.rb 
    create  spec/views/posts/show.html.haml_spec.rb 
    invoke  helper 
    create  spec/helpers/posts_helper_spec.rb 
    create  spec/routing/posts_routing_spec.rb 
    invoke  rspec 
    create  spec/requests/posts_spec.rb 
    invoke helper 
    create  app/helpers/posts_helper.rb 
    invoke  rspec 
    invoke assets 
    invoke coffee 
    create  app/assets/javascripts/posts.js.coffee 
    invoke scss 
    create  app/assets/stylesheets/posts.css.scss 
    invoke scss 
identical app/assets/stylesheets/scaffolds.css.scss 

です。

Rails 3.0では、これはRspec用のものだけでなく、ジェネレータ全体のオプションでした。 Railscast 216 for Generators in Rails 3を参照してください。おそらく、あなたのニーズを満たすRails 3.0.xのジェネレータを見つけるでしょう。

+0

hmmリンクで提供されているドキュメントのように、-c、--singletonオプションを渡す必要があります。しかし、私はそれをコマンドラインに入力すると、通常のタイプのスキャフォールドジェネレータを実行しました。 – tomciopp

0

私はこれに同意してGithub issueを作成しました。それが役に立つなら、これに従ってください。しかし、これを修正する唯一の方法は、手動で問題を解決することだとわかりました。それは手で名前を変更することを意味します。私はあなたがそれをしたくないと知っていますが、私はそれが唯一の方法であることをいくつか見出しました。

+0

mliebeltの上記の解決策を参照してください – Brandt

関連する問題