Michi’s blog » archive for 'Ruby'

Riding the Google Charts API bandwagon

  • December 13th, 2007

Last week, the news hit the blogosphere that Google had released a beta API for generating graphs using a reasonably easy and transparent GET parametrisation.

Inspired by this, and inspired by my early playing around with Ruby on Rails, I decided to whack together a Rails plugin that takes care of building the Google Charts IMG tag using what I hope is reasonably easy to use syntax.

I have a test-site using random data up for playing around with it.

The test-site as such runs on Ruby on Rails. The controller does some parsing and setting up of relevant arrays, and primarily generates random data for plotting.

The view has the following source code:

<%= google_chart(@data, @alt_text, @options)  %>

<p><% form_tag "" do %>

<label for="options[type]">Type</label>
<%= select_tag "options[type]", options_for_select(@typeopts,@options["type"])
%>

<label for="options[title]">Title</label>
<%= text_field_tag "options[title]", @options["title"] %>

Pluralization in Rails

  • December 9th, 2007

So, there is this one big and neat framework called Rails, building on top of this one neat new programming language called Ruby.

And one of the things that makes Rails so Damn Neat is that if you only set things up the right way around, it guesses almost everything you need it to guess for you.

One of the ways it does this is by pluralization. Basically, the model Foo has a model defined in app/model/foo.rb and it accesses the database table foos.

So, when talking a good friend through the basics, we created the table persons and generated the model Person. And promptly got an error from the framework.

It turns out that the pluralization of person is people. I wonder what else irregularities they built into the system. If I have a model called Index, does Rails expect it to read from the database table indexes or from indices?

post navigation
about
Michi is a recent PhD working in homological algebra. This blog is his outlet for texts with some manner of thought put into them. Over at his LiveJournal intimate details and streams of consciousness might be found.
Not all here is mathematics. All here, though, are my personal thoughts and opinions. Please read the about page (linked above) for more details.
This blog uses statcounter.com for logging and traffic analysis. In order to identify return visitors, this site will issue a cookie on viewing the blog.
buttons

latest comments
search
blogs and links
the rdc* theme