Skip to content

Instantly share code, notes, and snippets.

@robyurkowski
Created July 27, 2010 20:04
Show Gist options
  • Save robyurkowski/492776 to your computer and use it in GitHub Desktop.
Save robyurkowski/492776 to your computer and use it in GitHub Desktop.
So I have a model named Droplet. A droplet is essentially a catch-all status update. It looks like this:
Droplet
-------
- id
- title:varchar(255)
- body:varchar(255)
- user_id:int(11)
The body field stores each status update. In order to keep the interface simple, the boss wants to be able to just keep typing in the same text field when he wants to create a blog entry. Back-end code (which isn't REALLY the issue here; I know how to implement either solution) checks the length of the posted body param. If it's longer than 255 characters, it stores it as a blog entry. Otherwise, it stores it in the body attribute.
The question at hand is:
1. Do I add an additional field to Droplet -- i.e. 'blog:blob', and store the text data there?
2. Do I create a separate model named Blog and relate it to a Droplet via has_one? This has the added bonus of letting me call Blog.all later.
I have to keep the Droplet item loading reasonably quick. Other than that, I'm welcome to suggestions as to which I choose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment