proper way to generate REST API?

I’m trying to figure out the “correct” commands for scaffolding out a REST API, i.e. something that will accept JSON, but not present a view.

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

will generate the models controllers, and views, whereas I don’t need any of the ERB stuff since there is no web view.

rails generate resource Post name:string title:string content:text

Generates the database stuff, but doesn’t seem to fill out the controller at all.

What’s the best way to approach this?

Brendan Miller wrote in post #1110215:

I'm trying to figure out the "correct" commands for scaffolding out a REST API, i.e. something that will accept JSON, but not present a view.

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

rm app/views/posts/*

rails generate resource Post name:string title:string content:text

rails generate api_scaffold Post name:string title:string content:text

After creating your own api_scaffold rake task, of course. You should be able to base it on the normal rails scaffolding task and remove the parts that generate the views. Just guessing since I've not looked at the Rails rake tasks in detail, but if you learn a bit about rake it shouldn't be that difficult.

What's the best way to approach this?

Simplest is obviously to just remove the generated views, but the "best" might be to create you own rake task.