links
300 Images From 1800 Sites
Punctuated Productivity
ascii table
brainjar.com: css positioning
Catman's Reference Guide to XHTML 1.1
Catman's XHTML 1.1 Elements and Attributes Reference Guide
citeseer
Color Scheme Generator
common errors in english
cool images
Copying music between authorized computers with iTunes for Windows
css layout-o-matic
daypop
del.icio.us
elegant hack
emacs wiki
floatutorial
imho...
keystroke shortcuts for windows xp
mozilla keyboard shortcuts
NameVoyager
perldoc.com
programming language popularity
regular expression tester
selectoracle
short url services
simple urls for search engines
the unix acronym list
yahoo dictionary
most read last 60 days: apache / fcgi / debian / rails (199)
installing ruby and rails on debian (158)
hard disk failure (126)
audiotron to audioscrobbler: atronscrobbler (123)
the lighter side: japanese error messages (120)
categories
cygwin / linux / unix
emacs
entertainment
government
health
restlater
ruby on rails
software development
system administration
textpattern
web technologies
sections
about
article
photos
portfolio
recently
Citizen’s Briefing Book
Tbone walking in the Park
rav this!
I'll rest later...
please don't feed the rails programmers
replication in rails
apache / fcgi / debian / rails
miguel's hell of gratuitous rewriting
favorite sig lines
listening reimplemented in ruby on rails
hard disk failure
maxloss
got backups?
installing ruby and rails on debian
hëävy mëtäl ümläüt
the lighter side: japanese error messages
home network performance
installing atronscrobbler on windows using cygwin
audiotron to audioscrobbler: atronscrobbler
lessons learned in electronic media
Do you know about the Rails Application Visualizer.

This thing is about the easiest thing in the world to use. You got to love it when the instructions include:
3. Chuckle and execute rake visualize!
I keep the model view of my application on my desk. The text is getting so small I’ll soon have to either use a magnifying glass or at least print it on larger paper.
* * *
permalinkOne of my early rails projects is a to-do list. But this is no ordinary to-do list. Think of it as a team to-do list. It’s called RestLater and you can find it at http://restlater.com.
Team? Yes, that’s right. It’s for teams. It helps you work together effectively.
The problem is simply this: Often there is a small group of people that need to work together to get some set of tasks done. Restlater is a service that allows you to specify the team members and the tasks. Then team members can go about their work. As they complete tasks they mark them completed on Restlater. Since all team members are viewing the task list on-line they all know what tasks are not complete, which have been completed and by who.
Restlater strives to provide this simple functionality simply. I hope that anyone can get started immediately. However it’s not simple enough — yet. Just be aware that simple will continue to be a goal for this service.
I think one of the hardest things to do in ASP services is to guard against unauthorized access by authorized users. Think about that a minute. Guard against unauthorized access by authorized users. How do we as developers traditionally do this? Well, most of the time we put a bunch of “if” statements in our code. And we add “where” clauses to our SQL. Most of us code very carefully in these situations, and we hold our breath during releases. You always wonder if you covered every situation.
One approach is to push the access control down into something beyond the normal coding realm. Get it right there and you don’t have to worry. But this is normally pretty hard to do.
Restlater is implemented using Ruby on Rails. Rails has an object/relational mapping API called ActiveRecord. For this project I modified ActiveRecord, overriding many of the methods with versions that check access. The methods work the same, but they only operate on data that is available to the logged in user. I still add many of the normal ‘if’ statements so that the UI is friendly. But if I miss one, and an attempt is made to access, modify or delete a record that the current user doesn’t have specific access to, an exception is thrown — or in some cases the record is simply not found, as if it didn’t exist.
There is still a lot to be done to improve security. Rest assured, this is important to me.
A service like restlater needs to be there. If you can’t depend on it you will not use it. And it needs to be responsive. This is something I’m watching and will continue to improve upon.
One of the reasons for this blog entry is to record the project stats. Here they are:
+----------------------+-------+-------+---------+---------+-----+-------+ | Name | Lines | LOC | Classes | Methods | M/C | LOC/M | +----------------------+-------+-------+---------+---------+-----+-------+ | Helpers | 69 | 58 | 0 | 8 | 0 | 5 | | Controllers | 268 | 223 | 4 | 24 | 6 | 7 | | APIs | 0 | 0 | 0 | 0 | 0 | 0 | | Components | 0 | 0 | 0 | 0 | 0 | 0 | | Functional tests | 496 | 301 | 6 | 57 | 9 | 3 | | Models | 404 | 302 | 10 | 32 | 3 | 7 | | Unit tests | 590 | 476 | 6 | 54 | 9 | 6 | | Libraries | 87 | 35 | 0 | 9 | 0 | 1 | +----------------------+-------+-------+---------+---------+-----+-------+ | Total | 1914 | 1395 | 26 | 184 | 7 | 5 | +----------------------+-------+-------+---------+---------+-----+-------+ Code LOC: 618 Test LOC: 777 Code to Test Ratio: 1:1.3
* * *
permalink
My friend Jane Macfarlane and I did a presentation at the East Bay Ruby Meetup on Thursday, December 14, 2006. After a brief introduction we created a Ruby on Rails application…live.
Writing code is challenging, but becomes truly sporting when you have 20 or 30 people watching you. When I told some developer friends that I was doing this, I got replies like “Oh, this should be exciting” — and I don’t think they meant that in a good way. Of course we rehearsed and scripted the event so it went smoothly, for the most part.
One exciting moment for me occurred when I was trying to install the acts_as_authenticated plugin. The command failed and I was briefly baffled, when an audience member asked if it required network access. Of course this was the issue, but the bigger question to me was whether I was going to bump into similar issues through out the presentation — thankfully, I didn’t.
The concept was to build an application from start to finish in the allotted time of 1.5 hours. I’ve done this before and knew the application had to be simple, but I also wanted something that was not a standard rails demo applications: blog, todo list, or recipes. I really wanted to show some key features of rails and I wanted the process to have at least 2 major phases in order to show incremental development. Jane and I settled on an application to allow people to submit and vote on future topics for East Bay Ruby Meetup meetings. We called the application TopicVote.
My thanks go to William Sobel for doing the normally thankless job of organizing this meetup and this particular event.
For those that asked for the presentation/demo material, here it is.
If you want to run the application, of course you will need to have:
Then to install and run, you will need to:
Here are the files:
Finally, during the Q&A we briefly discussed a program called DENIM. For information on DENIM, please check out my DENIM article.
If you’ve read this far, please consider rating me at Working With Rails.
Thank you.
Comment [319]
* * *
permalinkI’m working on a project that has 3 tables that are very similar and each should have a very similar edit UI. Of course I don’t want to duplicate code or coding effort if I don’t have to. I’m always trying to explore new areas of ruby and rails and this seemed like a good opportunity.
My first thought was to copy the scaffolding generator. I think most of the generators are pretty trivial but scaffolding is significant since it does reflection on the database in order to build the new and edit forms. Copying and modifying the scaffold generator was a bigger job than I expected but I got it working. Since the scaffold generator invokes the model generator I ended up modifying model too.
A modified generater is neat because you can make a change to the generator and completely regenerate the model, controller and views instantly.
I wasn’t satisfied with this though. Basically I now had a lot of automatically generated code. In addition I worked on it longer than if I had simply used the default scaffold generator and modified the forms and controllers individually.
It seemed to me that if you can run a generator 3 times you should be able to refactor things so that you only have one copy of that code instead of 3.
I wanted to experiment with run time code generation like rails associations (and many other features of rails). So I modified the controller adding a method that would generate other methods—the methods that are normally generated when you use scaffolding.
In the end I found that my 3 models were not as close as I had originally thought. The exceptions required to get these techniques to generate all of the code created a lot of complexity that started spilling out to other parts of the system.
Bottom line: these are useful tools to have in your back pocket especially if you are building plugins or other reusable code.
However, they probably should not be used in building a single application due to the additional complexity and non-standard application structure.
Comment [325]
* * *
permalinkGetting ruby and rails to run on debian can be a challenge. One of the challenges is getting the fcgi gem installed. This page helped, but fell short. A few more hours of digging and I found the problem.
Here is what I did to install the fcgi gem on debian. I hope it saves you some time.
# aptitude install ruby1.8-dev
# wget http://www.fastcgi.com/dist/fcgi.tar.gz
# tar -zxvf fcgi-2.4.0.tar.gz
# ./configure
# make
# make install
# gem install fcgi
* * *