Skip to main content

Martin @web-strat.net

Martin @web-strat.net's Public Library

The Ruby Toolbox: Know your options!

  • Write real desktop apps with Ruby. Learn MacRuby at PeepCode!

Where can I find good examples of Rails applications? - Stack Overflow

    • On my drive I have a number of open-source Rails apps I have used for reference while learning Rails as also sanity checking that I am doing things the "rails-way":





      Beast and Mephisto are particularly valuable as they have been developed by high-profile members of the Rails community.

Acts As Taggable Tag Cloud

  • query = "select tags.id, name, count(*) as count"
    query << " from taggings, tags"
    query << " where tags.id = tag_id"
    query << " group by tag_id"
    query << " order by #{options[:order]}" if options[:order] != nil
    query << " limit #{options[:limit]}" if options[:limit] != nil
    tags = Tag.find_by_sql(query)
    end

Pragmatic Forums | Building external APIs for Rails web apps

    • I’m going through this at the moment as we’re adding an API to our research website.




      The things I’ve learnt so far are:




      • start with what you know – you already have the fundamentals of an API in your current URL’s – build on that. this is especially the case if you have ben RESTful
      • RoR makes it easier – especially the XML and JSON handling in recent RoR versions
      • rudimentary security is already in place in you current web app – but think about your authentication system. E.g. AuthLogic makes it real easy to use HTTP-Basic and extends well for other authentication systems
      • you will need to extend the API to explicitly expose resources you don’t currently. e.g if you have options lists in web forms, you’ll need to expose those items via the API for clients to use
      • you’ll need to tighten up your controllers and models, e.g. use attr_accessible and attr_protected properly so only the items you want exposed are exposed
      • make sure that the important stuff is in the models – the controllers should just be there to set things out to the user (especially important if your API and web URLs are not the same to keep things DRY)
      • an API is a contract – testing is pretty much mandatory to ensure the contract is and stays good
      • document thoroughly! RDoc is your friend here



      There are some design issues that need to be thought about – such as do you have your API the same as your regular RESTful URI’s? Whilst this is the easiest option, does it force you to match the API too closely to your website? what if you want/need to change things later on? Would it be better to have an explicit (and versionable) API URI structure?




      Hmm… maybe I need to go write this all down somewhere :)

A Real American Hero » Blog Archive » Building an API in Ruby on Rails








  • Building an API in Ruby on Rails


    March 5, 2009 – 12:31 pm <!-- by Erik Jacobs -->

    I know there are quite a few tutorials and links out there on building an API for your Ruby on Rails application, but I figured that I would document a little bit about how it was done for Riding Resource, but at a high level.  A partner had requested access to some of our data via an API, and wanted the results to be spit out as XML, so here’s a little bit about how that was done.

1 - 20 of 752 Next › Last »
Showing 20 items per page

Diigo is about better ways to research, share and collaborate on information. Learn more »

Join Diigo