If you're reading this blog you've probably already heard about Google's AJAX Library API on many other news sites like Slashdot.
I'm going to describe my simple process for setting up a RoR app to use Google to pull the APIs in a rails friendly way, throughout layouts, views, and helpers.
First, open up "app/helpers/application_helper.rb". Here, we are going to add a few tag methods to keep our views clean and also to keep our versions consistent.
def google_prototype_tag google_tag('prototype', '22.214.171.124') end
Now we need to include these tags in our layouts and views.
In my layout, I put this for a head:
<title><%= yield :title %> - My Site</title>
<%= stylesheet_link_tag 'mystyle' %>
<%= google_loader_tag %>
<%= yield :css_include %>
Now here is what my view looks like:
<% content_for :title do -%>Welcome<% end -%>
Now my title bubbles up, and my request for prototype bubbles up to the head for me, after the google loader.
The best part about this setup is that my versions will stay the same, and they only need to be changed in one place. And, if I ever decide to host the files locally, I just change the tags in one place, and make the google loader tag return "", until I fix all of the instances.