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.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f78b935829a8acb05efcd6cee060b130%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment