Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation on Post and Put methods #75

Open
ajbraus opened this issue Sep 27, 2013 · 4 comments
Open

Documentation on Post and Put methods #75

ajbraus opened this issue Sep 27, 2013 · 4 comments

Comments

@ajbraus
Copy link

ajbraus commented Sep 27, 2013

Hi, love rocket_pants as I am learning APIs. I think a big win for us nubes would be to include Post and Put requests (Create and Update methods) in the docs. Right now its just GET requests and index/show methods.

These examples are lacking here and in the linked sample app.

Thanks!

@mbhnyc
Copy link
Contributor

mbhnyc commented Sep 27, 2013

There's nothing different or fancy about processing requests like that - have you just tried following the samples in:

http://guides.rubyonrails.org/action_controller_overview.html

and

http://guides.rubyonrails.org/active_record_querying.html

@ajbraus
Copy link
Author

ajbraus commented Sep 27, 2013

Ok cool, those "expose" and "collection" methods were looking kinda special and I wasn't sure if there was a PUT and POST equivalent.

So I'll just do
def create
Post.create(params[:post])
end

etc.

Thanks!

@mbhnyc
Copy link
Contributor

mbhnyc commented Sep 27, 2013

expose/collection are purely to simplify OUTPUT of anything! so you can do:

expose Post.create(params[:post])

which will render out the result of the creation (i.e. the object itself), and if you do Post.create!() it'll render out the validation errors automatically without doing anything else.

kindof like magic, but it's not i promise.

(one more note: whenever you have a question like this, check the source first, expose is a super simple method and really just wraps some stuff around render_json)

@ajbraus
Copy link
Author

ajbraus commented Sep 27, 2013

See why we should add the examples? :o) Thanks!

~ Adam Braus
608-770-0230

On Friday, September 27, 2013 at 5:19 PM, mbhnyc wrote:

expose/collection are purely to simplify OUTPUT of anything! so you can do:
expose Post.create(params[:post])
which will render out the result of the creation (i.e. the object itself), and if you do Post.create!() it'll render out the validation errors automatically without doing anything else.
kindof like magic, but it's not i promise.


Reply to this email directly or view it on GitHub (#75 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants