A New World of Resources
Mon May 23 22:04:00 -0700 2011
Last year I attacked a long lost black sheep of the Rails family, ActionMailer. This was because I had a project that needed to use email and I found the current implementation, shall we say, somewhat lacking. This year, I’m turning my attention to really the only remaining black sheep left, ActiveResource.
ActiveResource needs to be upgraded to be a real citizen in the Rails 3 family, in fact, in the last few years there have only been very minor fixes to ActiveResource while the rest of the world moved forward.
So what do we have? Happily, working code.
ActiveResource, as it stands now, works for the simplest of cases. If you have a controller exposing a Rails REST based resource, and you point ActiveResource at it, you will be able to perform the basic CRUD operations you have come to know and love.
But if you want to go any further, you are on your own.
Associations with ActiveRecord objects don’t work, validations need attention, bulk updates and transactional support are missing entirely. The code is really as it was when it was first released.
With the world moving towards using rich clients that hit a back end API that abstracts the data layer, these things need to change. Having your front end client go to delete 100 records requiring 100 requests to complete is no fun, and a waste of time.
Sure you as a developer can dive in and create all these things. But that is the problem. With each developer rolling their own we end up with a mass of Rails apps that are all different, which increases the work load for all of us. ActiveResource must provide the same level of opinionated functionality as the rest of Rails. There needs to be a reasonable opinion on how to provide an API, a template that you can reasonably expect all Rails applications to follow.
The way I see it, there are two broad use cases for ActiveResource and the code that is exposed in the controllers. Firstly we have the “bolt on API”, this is the API that is simply added to existing controller code typically using respond_to and returning JSON or XML representations of objects.
The second type though is the pure API, these are the APIs that are built from the ground up only to talk to other systems, the API at rubygems.org is a good example of this. It is not a patch on existing functionality, but instead a core member of the entire application.
With the above in mind, I want to implement the following into ActiveResource:
- Opinionated way to produce a “pure API” with Rails (think “rails generate api” for Rails applications that need to expose a separate, formal API for rich clients)
- Support for bulk updates of objects to existing controllers (show_many, change_many, update_many and destroy_many) – see idea in David’s Gist
- Transactional support for bulk operations
- Support for multi type operations (for example, updating the post and the author at the same time) outlined in the Rails Conf talk by Yehuda Katz
- Association support – providing connections through to local ORMs
- Better validation handling and reliable ways to communicate error messages to client apps
The above is not an exhaustive list and I am interested in your comments. If you are interested in helping, send me an email or tweet to (@raasdnil)
I’ll be posting updates here and on my twitter feed as we move forward.
blogLater
Mikel




Wed May 02 13:38:00 -0700 2012
thanks for your contributions…
Thu May 03 23:49:26 -0700 2012
Natural resources are materials and components (something that can be used) that can be found within the environment. Every man-made product is composed of natural resources
Thu May 03 23:48:59 -0700 2012
Natural resources are materials and components (something that can be used) that can be found within the environment. Every man-made product is composed of natural resources
Fri May 04 05:04:57 -0700 2012
This is essential for even trying HTTP streaming via 3.1. Are you interested in this?
plumbers
Fri May 04 05:05:11 -0700 2012
This is essential for even trying HTTP streaming via 3.1. Are you interested in this?
plumbers
Tue Nov 08 19:26:39 -0800 2011
Great news! I hope You’ll be able to finish the work in reasonable amount of time. :)
Wed Nov 30 08:03:29 -0800 2011
One more thing that is sorely missing is lazy eval of AResource ala ARecord. This is essential for even trying HTTP streaming via 3.1. Are you interested in this? I am planning on implementing this sometime soon (within the next couple of days) – so if you are interested, please contact me asap.
Wed Nov 30 14:26:15 -0800 2011
One more thing that is sorely missing is lazy eval of AResource ala ARecord. This is essential for even trying HTTP streaming via 3.1. Are you interested in this? I am planning on implementing this sometime soon (within the next couple of days) – so if you are interested, please contact me asap.
Wed Nov 30 14:50:41 -0800 2011
One more thing that is sorely missing is lazy eval of AResource ala ARecord. This is essential for even trying HTTP streaming via 3.1. Are you interested in this? I am planning on implementing this sometime soon (within the next couple of days) – so if you are interested, please contact me asap.
Tue May 24 04:49:20 -0700 2011
Nice!
I guess the associations between active resources and nested attributes are priority. At least for me :)
Good luck!
Tue May 24 20:00:04 -0700 2011
restfulie, links to find the api
Tue May 24 20:00:11 -0700 2011
restfulie, links to find the api
Wed May 25 03:46:47 -0700 2011
Great news! I hope You’ll be able to finish the work in reasonable amount of time. :)
Mon Jun 20 02:04:00 -0700 2011
Effectively it’s really necessary to improve ActiveResource!
Tue Jan 17 03:17:55 -0800 2012
This web site is really a walk-through for all of the info you wanted about this and didn’t know who to ask.
Sun Feb 05 20:12:47 -0800 2012
Great news! I hope You’ll be able to finish the work in reasonable amount of time. :)
Wed Feb 29 20:27:27 -0800 2012
This web site is really a walk-through for all of the info you wanted about this and didn’t know How to Get Scholarships who to ask.
Wed Feb 29 20:30:18 -0800 2012
This web site is really a walk-through for all of the info you wanted about this and didn’t know How to Get Scholarships who to ask.
Mon Mar 05 05:24:34 -0800 2012
I was thinking switch to Ruby long time ago, but didn’t have time to start learning about it, My be now is the moment.
Fri Mar 09 07:59:33 -0800 2012
Good Work ! This is essential for even trying HTTP streaming via 3.1. Thanks for posting!
Mon Mar 12 02:39:26 -0700 2012
That seems to be a good list of resources. I will use it for sure! You should post more often this kind of articles.
Mon Mar 19 07:30:31 -0700 2012
it is a good list of resources. I will use some for sure.
Tue Mar 27 08:24:59 -0700 2012
I will be sure to bookmark your blog and definitely will come back from now on. I want to encourage that you continue your great job.
Tue Mar 27 08:25:29 -0700 2012
I will be sure to bookmark your blog and definitely will come back from now on. I want to encourage that you continue your great job.
Fri Apr 20 04:54:11 -0700 2012
One more thing that is sorely missing is lazy eval of AResource ala ARecord. This is essential for even trying HTTP streaming via 3.1. Are you interested in this?
Sat Apr 21 02:51:39 -0700 2012
The way I see it, there are two broad use cases for ActiveResource and the code that is exposed in the controllers. Firstly we have the “bolt on API”, this is the API that is simply added to existing controller code typically using respond_to and returning JSON or XML representations of objects.