2015-12-03 130 views
0

我创建--api参数新的Rails应用程序,就像手动http://edgeguides.rubyonrails.org/api_app.htmlRuby on Rails的--api

rails new app2 --api 

脚手架我用

bin/rails generate scaffold People first_name:string last_name:string age:integer 

和Rails生成控制器,不仅行动对于json结果,并不需要“新建”和“编辑”动作,并且html渲染
同样它会生成

create  app/views/people 
    create  app/views/people/index.html.erb 
    create  app/views/people/edit.html.erb 
    create  app/views/people/show.html.erb 
    create  app/views/people/new.html.erb 
    create  app/views/people/_form.html.erb 

我不需要,因为我只需要API
为什么?
我希望收到的结果,就像我使用Rails的API宝石
的Rails的版本是4.2.5

回答

1

如果你只是想生成modelcontroller,你可以使用:

bin/rails generate resource People first_name:string last_name:string age:integer 
+0

我需要像“rails-api”gem这样的脚手架,但需要使用CRUD操作,但仅适用于json上的REST API。没有html模板和html操作 – Artik

0

我找到答案。 “--api”命令仅适用于5.0 Rails