Pregunta

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?

¿Fue útil?

Solución 3

Try these gems jbuilder rabl rails-api. You can see free railscasts for

Some other very good railscasts related to api

Otros consejos

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.

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top