Need help for writing Api in Rails 5

Hi All,

I am new to rails. I want to write restful api’s in rails. I start following the “API on Rails” book. By following that book, I come to know that there are lot of things are depreciated in rspec, I am getting bulk of error and all things are blown. Please anyone provide me step by step tutorial for writing Rest APi in rails 5

Thanks Tushar Garg

Can you provide the error logs?

I would hope this book tells you what versions of gems it was using! If so you can specify those in your Gemfile and things should work.

However, if the Rails version in question is no longer supported, then you're better off finding a current tutorial, API-specific or not.

Hi Hassan,

Those errors were related testing. Becoz lot of things in Rspec are depriciated, when I remove Rspec and testing part from it, then its working fine. I follow the given tutorial and the concept of Api is clear and I am able to write api in rails5.

Hi All,

I am new to rails. I want to write restful api’s in rails. I start following the “API on Rails” book. By following that book, I come to know that there are lot of things are depreciated in rspec, I am getting bulk of error and all things are blown. Please anyone provide me step by step tutorial for writing Rest APi in rails 5

Thanks Tushar Garg

Hi Edsil Basadre,

Those errors were related testing. Becoz lot of things in Rspec are depriciated, when I remove Rspec and testing part from it, then its working fine. I follow the given tutorial and the concept of Api is clear and I am able to write api in rails5. https://www.simplify.ba/articles/2016/06/18/creating-rails5-api-only-application-following-jsonapi-specification/

But "removing testing" to make it "work" is an extremely bad habit to get into.

If some methods shown in the old tutorial are deprecated, write your tests to use current ones. You will never regret knowing how to write good tests :slight_smile:

Hey Tushar,

There are a lot of great resources online for creating APIs in Rails 5 (with its new API-only mode).

One of my favorites is called Building the Perfect Rails 5 API Only App by Kam Low (which I wrote about).

Another that just caught my eye was this one called Best Practices for Designing a Pragmatic RESTful API by Vinay Sahni. It isn’t specific to Rails 5, but talks about API best practices and recommendations in general. Very comprehensive.

Hope those help!

Thanks bro for sharing this. I will check and implement it