Our First API (Example) - GoRails
Chris, at 10:33, when you open /api/v1/locations/1.json in your browser, I see that you can alternate between raw and parsed views of the json. Which plugin are you using for this?
I am excited about the upcoming API-related videos. A particular question I have and would love to see some aspect of it discussed in the videos is this: How to return custom error codes? http://stackoverflow.com/qu...
Some suggestions I found regarding this: https://blog.rebased.pl/201...
Awesome video, Chris! I built my first api this past weekend and struggled because there were so many different sources out there. Codeschool helped me out the most. But this video would have saved me a few hours!
Impeccable timing. I'm building an Android app with a Rails API as its back end. And just when I'm thinking "hmm I wonder how to handle authentication with APIs" in your video you say "we'll dive in talk about things like authentication... etc". :)
Great stuff Chris, 14 minutes set it all straight with how easy it is. Do you plan to do any stuff around Webhooks (generally, not just Stripe), rate limiting etc as well?
Also, any ideas when we could expect the next video around the API auth + error handling etc? :D
+1 vote for JWT!
Like building webhooks for your customers to use or consuming other service's webhooks?
First auth video will be next week. Going to be recording it tomorrow. :)
I guess I am interested in the versioning and authentication area of it.
Versioning: how to write DRY code with versioning, backwards compatibility without repeating your code.
Chris, I think that you have clearly hit a topic, that a huge group of people have interest in. As far as APIs are concerned, I believe you have material for many more videos :)
I wrote out a list of topics related to APIs and had like over 50 different episodes I could do. That's so many it could fill up the entire next year with only API content. Love it. :D
WTH? I'm about to unsubscribe after watching this video, Rails 5 has the API ONLY MODE and this video was published on December 20, 2016. Why you are showing us the old way of creating ROR APIs???
Hey Victor, please be constructive. Angry comments don't help anyone.
A common misconception like you have is that Rails API-only mode is how you should build all Rails APIs, which is flatly incorrect. In some specific cases where you don't want to render a website, you can use API-only mode to strip out most of the Rails functionality that's used for cookies and other web functionality but isn't needed for APIs. Since it removes a lot of Rails features, API-only mode should only be used when you know you really want to disable those features of Rails.
That's why it's not the default and why I'm not talking about it just yet. We will be covering this but it is not the "new way" of doing things as you claim. It is a way of doing things for a specific situation, not all situations.
So again, we're here to help each other learn these things, not shout angry comments at me about something that you believe is incorrect. It's not, and the whole reason I made this episode was to discuss how APIs are not a special thing like you claim. It's a common misunderstanding and one that we can fix if we talk about this stuff in-depth.
Next time instead of telling me I'm stupid, simply ask why I haven't talked about API-only mode and we can all have a much more constructive time together.
Chris-
Love to see file uploads through an API. If it was possible to do direct to S3 that would be the icing on the cake.
Thanks,
Dave
cool I am interested in learning how to use a rails controller for rendering json to use as a AngularJs restful api frontend.
Chris, adding the request.format = :json works only in Application Controller.
Tried to add in the show method directly, it is not working.
Any help to understand this?
You need to change ApplicationController to ApiController in locations_controller.rb.
I had to change the coffee-script version in the Gemfile.lockfile to 1.12.2 to get bundle install to work.