Reputation:
I want write api for my rails application and with authentication. I want to pass my associations data also but in selective and conditional manner.
If I use respond_to
block for that then there will be a lot of mess in my controller that i do not want any ways.
What is best way to accomplish this?
Upvotes: 1
Views: 1397
Reputation: 1303
Try these gems jbuilder
rabl
rails-api
.
You can see free railscasts for
Some other very good railscasts related to api
Upvotes: 0
Reputation: 314
If the purpose of your application is only API then you can go with RAIL_API Gem and your can configure you JSON reponse using RABL
Upvotes: 1
Reputation: 114
You can have a look at grape. It is a REST-like API micro-framework for Ruby, and it has a related gem grape-entity which defines the attributes to expose. They should be what you want to use.
Upvotes: 1