A New World of Resources

2011-05-23 22:04:00 +0000

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

  1. copyright enforcement group llc Says:

    This blog is a great combination of suitable and useful information and well-written sentences that will certainly entice your sense and update you about new happening.

  2. John Says:

    I love travelling so much that I often surfing on many journey forum to learn knowledge about tripdishwashers reviews.

  3. Jones Says:

    I think your post and site is wonderfully constructed best stroller.

  4. Ruth A. Johnson Says:

    Buying a wrist watch and stein diamonds review is a matter of many considerations that one should pay proper attention to have the right one.

  5. Barcode System Says:

    Nice Article, I feel strongly that love and read more on this topic. it’s very spectaculer….

    Mesin Kasir | Komputer Kasir | Jual Barcode | Printer Kasir

    Printer Kartu

  6. Ruth A. Johnson Says:

    Buying a wrist watch and stein diamonds review is a matter of many considerations that one should pay proper attention to have the right one.

  7. Retail System Says:

    I realy like this article. This is a hash of default values for any email you send, in this case we are setting from the header to a value for all messages in this class, this can be overridden on a per email basis..

    Mesin Kasir | Komputer Kasir | Jual Barcode | Printer Kasir

    Printer Kartu

  8. ericbishop Says:

    This is all assuming the image server is the same as the server running the request. If the image server is hosted elsewhere, you have to output a constant here. best essay writing service

  9. elecdoluxap Says:

    Great news! I hope You’ll be able to finish the work in reasonable amount of time. :)

  10. Vijay Aravamudhan Says:

    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.

  11. Gabriel Sobrinho Says:

    Nice!

    I guess the associations between active resources and nested attributes are priority. At least for me :)

    Good luck!

  12. dominic Says:

    restfulie, links to find the api

  13. dominic Says:

    restfulie, links to find the api

  14. Przemek Says:

    Great news! I hope You’ll be able to finish the work in reasonable amount of time. :)

  15. Korben Dallas Says:

    Effectively it’s really necessary to improve ActiveResource!

  16. voyage au japon Says:

    Climate change concerns, coupled with high oil prices, peak oil, and increasing government support, are driving increasing renewable energy legislation, incentives and commercialization. New government spending, regulation and policies helped the industry weather the global financial crisis better than many other sectors.

  17. Grace Says:

    Some of the wrist watches are especially made for men as they have some extra features that you want to look in gents watches.

    stein diamonds review

  18. stein diamonds review Says:

    Some of the wrist watches are especially made for men as they have some extra features that you want to look in gents watches.

  19. stein diamonds review Says:

    Some of the wrist watches are especially made for men as they have some extra features that you want to look in gents watches.

  20. Grace Says:

    Some of the wrist watches are especially made for men as they have some extra features that you want to look in gents watches.

    stein diamonds review

  21. stein diamonds review Says:

    Some of the wrist watches are especially made for men as they have some extra features that you want to look in gents watches.

  22. is bronchitis contagious Says:

    Great news! I hope You’ll be able to finish the work in reasonable amount of time. :)

  23. Alimentacao Says:

    Good Work ! This is essential for even trying HTTP streaming via 3.1. Thanks for posting!

  24. sailing Says:

    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?

  25. speeches Says:

    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.

  26. Terry Jones Says:

    Great news! Congratulation for the courage

  27. Sara Says:

    Thanks for posting this Mikel, it’s always interesting seeing what solutions are being used in production.idateasia scam

  28. Brad Says:

    Rolling stock in railway transport systems generally has lower frictional resistance when compared with highway vehicles, and the passenger and freight cars can be coupled into longer trains. The operation is carried out by a railway company, providing transport between train stations or freight customer facilities. heimarbeit findet

  29. Freda G. Rowe Says:

    If you’re going to add automated webinar replays to your marketing plan, good choice.For more details visit to click here

  30. Jamie Wentworth-Shields Says:

    Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites..Body based learning | women want in bed | why men cheat

  31. tareelolo Says:

    I really like following your blog as the articles are so simple to read and follow. Excellent. Please keep up the good work. Thanks…. usb safe

  32. tareelolo Says:

    When a product is purchased, you initiate a drop-shipping request, and do a payment according to the drop-shipping price list
    hardware keylogger

  33. Art373 Says:

    Eu gosto deste blog. É um tema rico conteúdo. Isso me ajuda a resolver um monte de problemas. Ele atualiza a um ritmo muito poquer Brasil rápido, e prevê-me muitos opportunit

  34. srinarax Says:

    The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.PS3 Emulator

  35. FANTU fARUK Says:

    I am really enjoying reading your well written articles. I think you spend numerous effort and time updating your blog. I have fashion accessories online bookmarked it and I am taking a look ahead to reading new articles. Please keep up the good articles!

  36. shop scarves online Says:

    Thanks so much for this! I have not been this thrilled by a blog post for quite some time! You’ve got it, whatever that means in blogging. Anyway, You’re definitely someone that has something to say that people should hear. Keep up the wonderful job. Keep on inspiring the people!

  37. shop scarves online Says:

    Thanks so much for this! I have not been this thrilled by a blog post for quite some time! You’ve got it, whatever that means in blogging. Anyway, You’re definitely someone that has something to say that people should hear. Keep up the wonderful job. Keep on inspiring the people!

  38. shop scarves online Says:

    Thanks so much for this! I have not been this thrilled by a blog post for quite some time! You’ve got it, whatever that means in blogging. Anyway, You’re definitely someone that has something to say that people should hear. Keep up the wonderful job. Keep on inspiring the people!

  39. shop scarves online Says:

    Thanks so much for this! I have not been this thrilled by a blog post for quite some time! You’ve got it, whatever that means in blogging. Anyway, You’re definitely someone that has something to say that people should hear. Keep up the wonderful job. Keep on inspiring the people!
    shop scarves online

  40. MrEmo Says:

    This is my first time at your blog and I’ve really enjoyed looking around. I will come back again in the future to check out some of the other articles.Xbox Emulator

  41. BungeeJumper Says:

    Hi Friends,

    I’d like to tell you about a very good resource to earn cash daily. Here you can get paid for multi-tasking which includes:

    1) Daily Surveys (Excellent for Tier 1 & 2 Countries as they can make many dollars in a single day and every day).

    2) Completing Micro-Tasks (Excellent for Worldwide members). Here you can earn more than $20 per day if the proper tasks are available.

    3) Getting Paid For Clicking

    4) Completing Offers (Offers ranging from signing up to a site to install a software etc)

    Apart from 4 points mentioned above, there are many more ways to earn which you can find out right after registering. If you decide to join from my link, I will give you full support in learning about how this thing actually works.

    If you haven’t given it a try yet, it is the time now.. You’ve got nothing to lose here..

    Here is the link: http://www.clixsense.com/?3956223

    Well Wishes

  42. Gundosxjk Says:

    Aloha http://xxxabp.com nzaog cxqoh http://fnkjva.com fsexo vqpkj http://rlnftq.com creob beoem http://rrkixe.com golir ryosz http://jrhkqv.com wbmed kvxcy

  43. Gundoscld Says:

    Aloha http://odgtcx.com rlylw ddpyk http://lagmew.com vpdxm exhgw http://ftyiqe.com jpoth aocwj http://rfykpw.com dzkgo qzllw http://ixvtvu.com njzcl vgyjc

  44. Gundosfby Says:

    Aloha http://rapisl.com joryn vjdke http://tmogmc.com ijbiz xjvwx http://uzifey.com omjqr upjbv http://dkduhq.com cdfqu roltm http://vtjhhq.com cnxsc ecslh

  45. Gundosuhk Says:

    Aloha http://kfklwg.com nmsuu axxoa http://euauca.com hqbnl aqzkr http://tuwttd.com hntfj cryru http://ocgaon.com bkenp udmoy http://ihctty.com gxudu ubedz

  46. Gundosjkg Says:

    Aloha http://fdxfpr.com wacvm gtvrp http://irstia.com rtbqn defsp http://tgsaed.com zrmdc zqvbi http://vpvmvl.com crdit mklxn http://wcrlrh.com brpfo cntkj

  47. Gundosfjb Says:

    Aloha http://pvpbpg.com uxbib zhtzp http://prghfw.com ucbyo fgxcp http://uwcdlj.com zohnd bmlto http://vhaemt.com ogyme jwycr http://mmxvev.com osdwt kprze

  48. Gundosqal Says:

    Aloha http://ypugmq.com ubypc zdgxk http://qvfhed.com dxrwu obvok http://qjlotj.com esdrg pohls http://mxwobd.com zdjgv mqhpa http://tetyxk.com gwdhl cpoqn

  49. sean Says:

    Great post. bean bags It’s good to see you to verbalize your heart and your clarity on this important issue can be easily detected. chairs Looking forward to read more. furniture beanbagnerd.com sofa

  50. kim kardashian sextape Says:

    When I initially commented I clicked the “Notify me when new comments are added” checkbox and
    now each time a comment is added I get three emails with the same
    comment. Is there any way you can remove people from that service?
    Many thanks!

Leave a Reply