grafitti on a GoC grain transport car
Tag: rails
Getting Things Done with Tracks
I've been using an OmniOutliner document to track tasks and hopefully prevent things from slipping through the cracks. It works quite well, especially when combined with kGTD to help prioritize and filter tasks as they start to pile up, but it's limited to a file on one computer. So, I can't easily add stuff from my Powerbook at home. And I can't access it when I'm not sitting in front of my G5. Sure, I can sync the file, and export it to the web, and print it, and sync it to my iPod, and to iCal, etc… but that's a pain, and not bulletproof.
I was doing some Googling for other "getting things done" packages, and found a reference to Tracks. It's a Ruby on Rails app that provides the streamlined context/project interface on top of a plain to-do list. So, I threw a copy of it on my Dreamhost server (it's got all of these bells and whistles just sitting idle, which would be a shame). It Just Worked™. I had to refer to the Dreamhost wiki to see how to best set up a Rails app to be served by Apache, but that was pretty darned easy.
The hardest part of the whole install was figuring htf to create an account – open the "signup" url, and you're good to go.
Performance is a bit lacking, but the entire network is feeling slowish today. It's not fatally slow, anyway. I've added in most of my current projects, and it's already helped me to see at a glance what's the most important set of tasks to be working on.
And it's the first non-Drupal tool I've installed in a while, which is a welcome change 🙂
Tracks – Getting Things Done in Rails
Update: Bonus. Now I’ve got multiple RSS feeds to keep me up to date on upcoming important tasks and deadlines…
I've been using an OmniOutliner document to track tasks and hopefully prevent things from slipping through the cracks. It works quite well, especially when combined with kGTD to help prioritize and filter tasks as they start to pile up, but it's limited to a file on one computer. So, I can't easily add stuff from my Powerbook at home. And I can't access it when I'm not sitting in front of my G5. Sure, I can sync the file, and export it to the web, and print it, and sync it to my iPod, and to iCal, etc… but that's a pain, and not bulletproof.
I was doing some Googling for other "getting things done" packages, and found a reference to Tracks. It's a Ruby on Rails app that provides the streamlined context/project interface on top of a plain to-do list. So, I threw a copy of it on my Dreamhost server (it's got all of these bells and whistles just sitting idle, which would be a shame). It Just Worked™. I had to refer to the Dreamhost wiki to see how to best set up a Rails app to be served by Apache, but that was pretty darned easy.
The hardest part of the whole install was figuring htf to create an account – open the "signup" url, and you're good to go.
Performance is a bit lacking, but the entire network is feeling slowish today. It's not fatally slow, anyway. I've added in most of my current projects, and it's already helped me to see at a glance what's the most important set of tasks to be working on.
And it's the first non-Drupal tool I've installed in a while, which is a welcome change 🙂
Tracks – Getting Things Done in Rails
Update: Bonus. Now I’ve got multiple RSS feeds to keep me up to date on upcoming important tasks and deadlines…
Rails Bookmark Manager – now with hot “AJAX” action
I followed a howto for adding that hot AJAX loving to a Rails app, and now my gestating bookmark manager has a slick add-a-new-bookmark-without-reloading-the-page form, making it feel pretty responsive. I really wish del.icio.us had implemented that – it takes a LONG time to reload the page (with huge tag cloud) when adding a bookmark…
Anyway, I pieced together code from a howto and a wiki page, and it took me maybe 30 minutes to get it going (with Family Guy playing in the background, so not 100% attention-requiring).
It’s not perfect – I have to clean up the new-record-displaying code – but it works pretty darned well. The newly saved bookmark is displayed at the top of the bookmarks list pretty quickly, with no noticeable lag.
I followed a howto for adding that hot AJAX loving to a Rails app, and now my gestating bookmark manager has a slick add-a-new-bookmark-without-reloading-the-page form, making it feel pretty responsive. I really wish del.icio.us had implemented that – it takes a LONG time to reload the page (with huge tag cloud) when adding a bookmark…
Anyway, I pieced together code from a howto and a wiki page, and it took me maybe 30 minutes to get it going (with Family Guy playing in the background, so not 100% attention-requiring).
It’s not perfect – I have to clean up the new-record-displaying code – but it works pretty darned well. The newly saved bookmark is displayed at the top of the bookmarks list pretty quickly, with no noticeable lag.
Fun with Rails – Bookmark Manager
I made some time to sit down and play with Rails this evening, and thought I’d work on a simple Bookmark Manager (ala del.icio.us) – a piece of software that I am sorta familiar with, since I use del.icio.us a fair bit, and have some ideas that I think would improve the service. So, I’ll try mocking them up in Rails to give me something to chew on while I learn…
So, about half an hour into it, and I have a barebones app that lets me add new bookmarks (complete with title, description, rating, date added, url, etc…), and list existing bookmarks.
Next, to try to work in the concept of Users, and tie bookmarks to specific users. Then, to try to do something interesting with the connections that can happen when multiple users bookmark the same resource, or similar resources, or tag them differently, or give them different ratings, etc…
I’m really liking the concept of Scaffolding in Rails. It feels very similar to starting a WebObjects application via DirectToWeb, and slowly overriding the default functionality as you need to. I also really like the strong MVC separation. Controller files (.rb
– analogous to the WebObjects .java files) contain the business logic, while View files (.rhtml
– analogous to the WebObjects .html and .wod files merged?) contain HTML with bindings to the methods and variables in the controller.
Almost forgot – I only “wrote” about 3 lines of code. Still, there were several files automagically generated by Rails, and a couple of the .rhtml files with html and bindings, but still – very little actual code to write/manage.
I think I’m really going to like Ruby, as well. It’s easily readable without being annoyingly verbose. It’s nicely object oriented, without being too abstract. It’s interpreted, so it’s easy to see code “live” as you tweak it.
I’ll play with this app over the next few days/weeks to see what I can come up with. If it gets stable enough, I might deploy it on my desktop box back in the office…
Here’s the basic database schema I’m working toward. I still have to think out the bookmark –> tag relationship. I want Tags to be primitive “nouns” – not belonging to any user, and being linked to from Bookmarks through a join table. Adding tags is just a matter of ensure the “noun” exists, and creating (or removing) a join to it.
Update: Thanks to a tip from Hunter, I checked out the acts_as_taggable
plugin/extension/whatever for Rails (description here). Basically, you just drop this bad boy into place, and declare in your controller that the class acts_as_taggable
– then, the plugin takes care of managing a many-to-many relationship between that class and the tags.
Sample code from the description page for acts_as_taggable
:
class Photo < ActiveRecord::Base acts_as_taggable end elephant = Photo.find(4437) elephant.tag 'zoo animals nature' elephant.tagged_with?('urban') # => false elephant.tags.size # => 3 elephant.tag_names # => [ 'zoo', 'animals', 'nature' ]
Can it get any easier than that? It’s doing exactly what I was describing as wanting, but For Free. Sweet.
Update 2: Yes, it can get easier. And more powerful. The developer of acts_as_taggable
reworked the mixin/plugin after some thought, and came up with something even cooler (documentation here).
In poking around some of the Rails sites, I keep thinking that although it’s still a bit immature (it just hit 1.0 a month ago), it “feels” like WebObjects, but based on Open Source from soup to nuts, and with an apparently vibrant and cool developer community. WebObjects is waaaaay more mature, but isn’t Open Source (hence the licensing fiasco this summer), and it feels like the developer community may be atrophying a bit (although I could be wrong on that – I hope I am).
Update 3: About an hour into noodling with the acts_as_taggable mixin, and I have a fully folksonomic bookmark manager. I’ve got a simple form that lets me add bookmarks, complete with a freeform text field for entering tags, which get bursted into individual Tag rows with the appropriate join table invisibly managed.
I’ve got some more work to do to clean it up, and then I want to add in the concept of users – which apparently is absolutely trivial in Rails. Then, add in some OPML and RSS exports, and support for bookmarklets, and perhaps implementing part of the del.icio.us API on the back end to allow other things to talk to it, and I’ve got a decent bookmark manager, with only a handful of code written. Sweet.
I made some time to sit down and play with Rails this evening, and thought I’d work on a simple Bookmark Manager (ala del.icio.us) – a piece of software that I am sorta familiar with, since I use del.icio.us a fair bit, and have some ideas that I think would improve the service. So, I’ll try mocking them up in Rails to give me something to chew on while I learn…
So, about half an hour into it, and I have a barebones app that lets me add new bookmarks (complete with title, description, rating, date added, url, etc…), and list existing bookmarks.
Next, to try to work in the concept of Users, and tie bookmarks to specific users. Then, to try to do something interesting with the connections that can happen when multiple users bookmark the same resource, or similar resources, or tag them differently, or give them different ratings, etc…
I’m really liking the concept of Scaffolding in Rails. It feels very similar to starting a WebObjects application via DirectToWeb, and slowly overriding the default functionality as you need to. I also really like the strong MVC separation. Controller files (.rb
– analogous to the WebObjects .java files) contain the business logic, while View files (.rhtml
– analogous to the WebObjects .html and .wod files merged?) contain HTML with bindings to the methods and variables in the controller.
Almost forgot – I only “wrote” about 3 lines of code. Still, there were several files automagically generated by Rails, and a couple of the .rhtml files with html and bindings, but still – very little actual code to write/manage.
I think I’m really going to like Ruby, as well. It’s easily readable without being annoyingly verbose. It’s nicely object oriented, without being too abstract. It’s interpreted, so it’s easy to see code “live” as you tweak it.
I’ll play with this app over the next few days/weeks to see what I can come up with. If it gets stable enough, I might deploy it on my desktop box back in the office…
Here’s the basic database schema I’m working toward. I still have to think out the bookmark –> tag relationship. I want Tags to be primitive “nouns” – not belonging to any user, and being linked to from Bookmarks through a join table. Adding tags is just a matter of ensure the “noun” exists, and creating (or removing) a join to it.
Update: Thanks to a tip from Hunter, I checked out the acts_as_taggable
plugin/extension/whatever for Rails (description here). Basically, you just drop this bad boy into place, and declare in your controller that the class acts_as_taggable
– then, the plugin takes care of managing a many-to-many relationship between that class and the tags.
Sample code from the description page for acts_as_taggable
:
class Photo < ActiveRecord::Base acts_as_taggable end elephant = Photo.find(4437) elephant.tag 'zoo animals nature' elephant.tagged_with?('urban') # => false elephant.tags.size # => 3 elephant.tag_names # => [ 'zoo', 'animals', 'nature' ]
Can it get any easier than that? It’s doing exactly what I was describing as wanting, but For Free. Sweet.
Update 2: Yes, it can get easier. And more powerful. The developer of acts_as_taggable
reworked the mixin/plugin after some thought, and came up with something even cooler (documentation here).
In poking around some of the Rails sites, I keep thinking that although it’s still a bit immature (it just hit 1.0 a month ago), it “feels” like WebObjects, but based on Open Source from soup to nuts, and with an apparently vibrant and cool developer community. WebObjects is waaaaay more mature, but isn’t Open Source (hence the licensing fiasco this summer), and it feels like the developer community may be atrophying a bit (although I could be wrong on that – I hope I am).
Update 3: About an hour into noodling with the acts_as_taggable mixin, and I have a fully folksonomic bookmark manager. I’ve got a simple form that lets me add bookmarks, complete with a freeform text field for entering tags, which get bursted into individual Tag rows with the appropriate join table invisibly managed.
I’ve got some more work to do to clean it up, and then I want to add in the concept of users – which apparently is absolutely trivial in Rails. Then, add in some OPML and RSS exports, and support for bookmarklets, and perhaps implementing part of the del.icio.us API on the back end to allow other things to talk to it, and I’ve got a decent bookmark manager, with only a handful of code written. Sweet.
Locomotive Ruby on Rails Distro for MacOSX
I just grabbed the Locomotive distro of Ruby on Rails for MacOSX – what a nice package! Includes the latest build of Rails, a fresh copy of Ruby, all of the database connectors, RMagick and ImageMagick, some AJAX libraries, and a bunch of other stuff to play with. Best part is – it’s all self-contained in the Locomotive application, so it won’t affect any of the other bits installed on my system.
Looks like the best Rails development system so far – no idea if it translates to a server very easily though.
I’m going to try to force myself to play with Rails for at least a couple of hours every week to see what I can get it to do. This is a good headstart for that…
I just grabbed the Locomotive distro of Ruby on Rails for MacOSX – what a nice package! Includes the latest build of Rails, a fresh copy of Ruby, all of the database connectors, RMagick and ImageMagick, some AJAX libraries, and a bunch of other stuff to play with. Best part is – it’s all self-contained in the Locomotive application, so it won’t affect any of the other bits installed on my system.
Looks like the best Rails development system so far – no idea if it translates to a server very easily though.
I’m going to try to force myself to play with Rails for at least a couple of hours every week to see what I can get it to do. This is a good headstart for that…
Playing with Rails
I played around with Rails a bit today. I contrived an excuse to attempt to create a generic “event management” application. I’m familiar with the basic requirements of the app, and have a need to have a generalizable app available to share with groups and departments on campus. And, I want to play around with Rails and ruby to get a feel for what it can do.
Well, I had better luck than Stephen did, but still not quite the magic “30 seconds from concept to production app” wonder that has been whipped up around Rails. I was following the “ToDo” howto and going off in my own direction. It didn’t work too well, and I’ve just realized that’s because the ToDo chapter is written to Rails 0.9, and I’ve got Rails 0.8.something installed. Apparently, Big Changes were involved going to 0.9. OK – so that should discount some of these issues/hangups.
At first, I was stumped trying to get Apache 1.3 (the stock install on MacOSX 10.4.2) playing with Rails. Thought I was following the instructions, but no joy. Gave up, and settled for the WEBrick server bundled with Rails. I got hung up for about 20 minutes because I didn’t realize that
./script/server
needs to be run as root
. I could have sworn that wasn’t required the last time I played with Rails. Once I figured that out, I got the free “hello world” page. Great. On to application creation… It would be cool(er) if the Hello World page gave me an interface to query any models/tables I’ve got configured. Kinda like D2W does…
I created a simple “event” model, with an “events_controller.rb”, and associated “events” views. I used the rails scripts to generate controllers and scaffolds, and ran rake to make sure it all checked out. I spent a lot of time trying to figure out which controllers should be created (Event vs. Events, and Person vs. Persons vs. People) but once I finally got the right controllers and scaffolds set up (and trimmed the excess tests from the various abortive attempts), then it was pretty clear sailing. The scaffolded app isn’t extremely high end – and as I’ve mentioned before, WebObjects DirectToWeb does a better job in some ways. But, the Rails scaffolded app is nice and clean, and looks rather straightforward to customize/extend. “Out of the box,” it gives you a barebones index (list all records), an inspect page, an edit page (with appropriate widgets – textfields, textareas, date selectors, checkboxes…), an add/insert page, and a delete function. Pretty straightforward – but still no Search. wtf. D2w does that really really well, even letting you pick which field to search on, and providing the appropriate widgets to help you enter search parameters.
I haven’t started looking at relations/joins – tying People to Events as either presenters or attendees – but that shouldn’t be too difficult. So far, I haven’t had to “write” any code, but invoking the various generation scripts should probably count – I didn’t get functionality for free, since I had to teach it via generation. D2W gives you lots “for free” by reverse engineering a database schema automatically. Generated code is still code – it’s just written by a script.
I’m going to read up on these before digging back in, though…
- manuals.rubyonrails.com
- documentation.rubyonrails.com
- Ruby on Rails manual – chapter 38: ToDo App
- Raible’s notes on the RoR session at OSCON2005
- … and any others I find…
I have to wonder, though… If O’Reilly is such a supporter of Rails, touting it as one of the Next Big Things, wtf isn’t there a book in The O’Reilly Safari???
I played around with Rails a bit today. I contrived an excuse to attempt to create a generic “event management” application. I’m familiar with the basic requirements of the app, and have a need to have a generalizable app available to share with groups and departments on campus. And, I want to play around with Rails and ruby to get a feel for what it can do.
Well, I had better luck than Stephen did, but still not quite the magic “30 seconds from concept to production app” wonder that has been whipped up around Rails. I was following the “ToDo” howto and going off in my own direction. It didn’t work too well, and I’ve just realized that’s because the ToDo chapter is written to Rails 0.9, and I’ve got Rails 0.8.something installed. Apparently, Big Changes were involved going to 0.9. OK – so that should discount some of these issues/hangups.
At first, I was stumped trying to get Apache 1.3 (the stock install on MacOSX 10.4.2) playing with Rails. Thought I was following the instructions, but no joy. Gave up, and settled for the WEBrick server bundled with Rails. I got hung up for about 20 minutes because I didn’t realize that
./script/server
needs to be run as root
. I could have sworn that wasn’t required the last time I played with Rails. Once I figured that out, I got the free “hello world” page. Great. On to application creation… It would be cool(er) if the Hello World page gave me an interface to query any models/tables I’ve got configured. Kinda like D2W does…
I created a simple “event” model, with an “events_controller.rb”, and associated “events” views. I used the rails scripts to generate controllers and scaffolds, and ran rake to make sure it all checked out. I spent a lot of time trying to figure out which controllers should be created (Event vs. Events, and Person vs. Persons vs. People) but once I finally got the right controllers and scaffolds set up (and trimmed the excess tests from the various abortive attempts), then it was pretty clear sailing. The scaffolded app isn’t extremely high end – and as I’ve mentioned before, WebObjects DirectToWeb does a better job in some ways. But, the Rails scaffolded app is nice and clean, and looks rather straightforward to customize/extend. “Out of the box,” it gives you a barebones index (list all records), an inspect page, an edit page (with appropriate widgets – textfields, textareas, date selectors, checkboxes…), an add/insert page, and a delete function. Pretty straightforward – but still no Search. wtf. D2w does that really really well, even letting you pick which field to search on, and providing the appropriate widgets to help you enter search parameters.
I haven’t started looking at relations/joins – tying People to Events as either presenters or attendees – but that shouldn’t be too difficult. So far, I haven’t had to “write” any code, but invoking the various generation scripts should probably count – I didn’t get functionality for free, since I had to teach it via generation. D2W gives you lots “for free” by reverse engineering a database schema automatically. Generated code is still code – it’s just written by a script.
I’m going to read up on these before digging back in, though…
- manuals.rubyonrails.com
- documentation.rubyonrails.com
- Ruby on Rails manual – chapter 38: ToDo App
- Raible’s notes on the RoR session at OSCON2005
- … and any others I find…
I have to wonder, though… If O’Reilly is such a supporter of Rails, touting it as one of the Next Big Things, wtf isn’t there a book in The O’Reilly Safari???
Getting feet wet with Rails
I finally made time to install Rails, planning on taking it for a test drive by making a Ruby on Rails version of the lightweight asset manager database we put together to store assets for Pachyderm.
Initially, I guess my install of Rails didn’t have MySQL support (why on earth wouldn’t that be included right out of the box?), and it kept barfing when it tried to connect. So, I installed or updated my MySQL kit via gem install mysql
and it was able to build a simple scaffolded app to let me create a single record via the dynamically generated interface. That was pretty cool – automatically figuring out which widgets should be used, etc… Very WebObjects D2W.
But, it barfed on a field name in the table – it didn’t like “type” at all. So, I renamed that field to “assettype” in my local copy of the database. Now I can create a record.
But, using the “list” action gives me an error:
ArgumentError in Asset#list
Showing /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/templates/scaffolds/list.rhtml where line #13 raised:
too few arguments.
Extracted source (around line #13):
10: <% for entry in instance_variable_get("@#{@scaffold_plural_name}") %>
11:
12: <% for column in @scaffold_class.content_columns %>
13: <%= entry.send(column.name) %>
14: <% end %>
15: <%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => entry %>
16: <%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => entry %>
So, I’m kinda stuck. Rails seems REALLY promising, and everything I’ve heard/read about it makes me want to do a lot of stuff in it. I love the develop/test/deploy distinctions built in from square one. I love the unit testing built in. I love Ruby (but haven’t really used it too much – it seems reminiscent of Lingo, but that’s because Lingo is another Smalltalk derivative, via Hypertalk). Also, Rails just celebrated its first birthday, and was apparently received extremely well at OSCon.
But, the magical “it will build a wonderful app with no code” hype fell a bit short for me, at least initially…
Update: Turns out it was choking on a field named “format” in my “assets” table. Renamed the field to “dc_format” and it appears to be happy… Now that the Rails setup seems to work, and I’ve debugged the database schema conflict, it’s actually very cool how it builds the dynamic app to manage records! Full “view”, “edit”, “add”, “list” and “delete” actions, with a totally usable (but rough) UI. Now to dig in to see how to customize the layout of the dynamic app…
So, for Google’s sake, Rails doesn’t like these field names for tables: type, format
– there may be others, but these are the ones that tripped me up so far…
Also, it’s a bit odd that the default scaffolding app doesn’t appear to provide a search function… I can list all records and page through them, but can’t do a quick search? WebObjects D2W does that right out of the box, even generating “advanced search” forms at will. Looks like Rails has a plugin gem to do this (Search Generator Gem), but it’s apparently a bit rough, and not included with Rails as a stock feature.
I finally made time to install Rails, planning on taking it for a test drive by making a Ruby on Rails version of the lightweight asset manager database we put together to store assets for Pachyderm.
Initially, I guess my install of Rails didn’t have MySQL support (why on earth wouldn’t that be included right out of the box?), and it kept barfing when it tried to connect. So, I installed or updated my MySQL kit via gem install mysql
and it was able to build a simple scaffolded app to let me create a single record via the dynamically generated interface. That was pretty cool – automatically figuring out which widgets should be used, etc… Very WebObjects D2W.
But, it barfed on a field name in the table – it didn’t like “type” at all. So, I renamed that field to “assettype” in my local copy of the database. Now I can create a record.
But, using the “list” action gives me an error:
ArgumentError in Asset#list
Showing /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/templates/scaffolds/list.rhtml where line #13 raised:
too few arguments.
Extracted source (around line #13):
10: <% for entry in instance_variable_get("@#{@scaffold_plural_name}") %>
11:
12: <% for column in @scaffold_class.content_columns %>
13: <%= entry.send(column.name) %>
14: <% end %>
15: <%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => entry %>
16: <%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => entry %>
So, I’m kinda stuck. Rails seems REALLY promising, and everything I’ve heard/read about it makes me want to do a lot of stuff in it. I love the develop/test/deploy distinctions built in from square one. I love the unit testing built in. I love Ruby (but haven’t really used it too much – it seems reminiscent of Lingo, but that’s because Lingo is another Smalltalk derivative, via Hypertalk). Also, Rails just celebrated its first birthday, and was apparently received extremely well at OSCon.
But, the magical “it will build a wonderful app with no code” hype fell a bit short for me, at least initially…
Update: Turns out it was choking on a field named “format” in my “assets” table. Renamed the field to “dc_format” and it appears to be happy… Now that the Rails setup seems to work, and I’ve debugged the database schema conflict, it’s actually very cool how it builds the dynamic app to manage records! Full “view”, “edit”, “add”, “list” and “delete” actions, with a totally usable (but rough) UI. Now to dig in to see how to customize the layout of the dynamic app…
So, for Google’s sake, Rails doesn’t like these field names for tables: type, format
– there may be others, but these are the ones that tripped me up so far…
Also, it’s a bit odd that the default scaffolding app doesn’t appear to provide a search function… I can list all records and page through them, but can’t do a quick search? WebObjects D2W does that right out of the box, even generating “advanced search” forms at will. Looks like Rails has a plugin gem to do this (Search Generator Gem), but it’s apparently a bit rough, and not included with Rails as a stock feature.