Life is a Mystery

8 February . Comment

Customizing the Ruby on Rails scaffold

I’m trying to learn Ruby on Rails this week. I found a wonderful book called Learning Rails that takes a non-evangelical tone, works from the ground up, and seems to match my style pretty well (also, I love the errata). But I quickly ran into an issue not covered in the book, how do I customize the Ruby on Rails scaffold?

I wanted to customize the scaffold so that I could replace the space indents with tabs (I know, silly me) and add JSON support to the scaffold. I found a post about how to accomplish this in Rails 3, but my Mac and the book both talk Rails 2. So I dug in a little bit. Here’s what I came up with for doing this in Rails 2.2.2 on a Mac.

Copy the original Ruby scaffold folder to a new folder somewhere reasonable with the name “my_scaffold”. (For the rest of these instructions you can replace “my” with anything reasonable.)

% cp -R /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/generators/components/scaffold /Users/myhome/Ruby/my_scaffold

Use a symbolic link to hook your new folder back to Ruby.

% ln -s /Users/myhome/Ruby/my_scaffold /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/generators/components/.

Change the name of the generator script to reflect your folder name.

% mv /Users/myhome/Ruby/my_scaffold/scaffold_generator.rb /Users/myhome/Ruby/my_scaffold/my_scaffold_generator.rb

Edit the generator script to modify the name of the object it creates. Change “ScaffoldGenerator” in the first line to “MyScaffoldGenerator” (adjust that name as necessary).

Now you have your own scaffold. You can edit any of the templates in /Users/myhome/Ruby/my_scaffold/templates and use the command “ruby script/generate my_scaffold MyObject my_field:string” to get rolling.

Note, the stylesheet.css name still conflicts with the same file in the original scaffold. If you want to resolve that conflict you can edit another line in the generator script. The line “m.template(’style.css’, ‘public/stylesheets/scaffold.css’)” would be made to refer to your new stylesheet name and the layout template should be changed accordingly. Notice that you don’t have to change the name of the actual “style.css” file.

Fair warning, I am on day two of Ruby and Rails. I know almost nothing, so use the above hint with care. Feel free to comment if you know more and want to offer a better suggestion!

ruby.jpg

5 February . Comment

MPR goes off the rails

Minnesota Public Radio (MPR) just announced that it is suing the Central Corridor project. That is a line I am not willing to cross, so Mary and I have suspsended our membership. I love MPR, but this is a boneheaded move! Here’s the note I sent them:

Please suspend our sustaining membership of MPR.

We are not willing to support an organization that is hindering as important a civic project as the Central Corridor rail line. We have been uncomfortable with your position for years because the Central Corridor plans were well known long before MPR renovated its space. As far as we are concerned, it is wholly MPR’s responsibility that it built studios as close to a known future rail line as it did. You should not be suing the state, but rather asking funders like us to up our contributions a bit to help you make necessary remediations.

Now that you have decided to sue the Central Corridor project we can no longer in good conscience support MPR. Maybe once this suit is over we will consider rejoining, we will see what the consequences of your action are. If this in any way leads to the demise or diminishment of the Central Corridor project, though, then you have lost us as member for good.

centralcorridor.jpg

2 February . Comment

Mosaic on a Stick

Years ago when we were renovating our attic I made the naive choice to do the tile in the bathroom myself. I was inspired by Hundertwasser, but really knew nothing about tile. Many calls around town revealed a new little shop near the fairgrounds, Mosaic on a Stick. Lori Green and Maria founded the Stick as not only a source for the materials that mosaic artists need, but also as an open studio and learning space to invite people to discover the artform and fall in love with building a world from broken pieces. Today I read this wonderful article about Mosaic on a Stick.

I enjoyed it immensely. The broken plate had been sitting on my dresser for months, and every time I looked at it, I had a twinge of sadness, remembering the whole plate it had once been. But once I started breaking it up into half-inch pieces, it turned into something else entirely. Raw bits ready to be reassembled into something new. Possibilities.

I enjoyed arranging the pieces onto the wood picture frame, like pieces in a puzzle. It required a quiet concentration that was soothing, and I soon lost track of time.

If you live in the Twin Cities, you should really stop by some time. It is a healing experience!

mosaic.jpg

29 January . Comment

FFR: commonsensemedia.org

The boys and I are thinking of escaping to a movie this evening and Nathaniel suggested going to see The Lovely Bones. As I was trying to assess it I stumbled upon commonsensemedia.org expecting a right-wing take down of a scary movie. Instead I found a thoughtful and well put-together review of the movie with great questions to think about with your kids and even reviews by parents and kids themselves. I found it very helpful and want to remember to come back and participate in this community down the road. Does anyone have other resources to suggest when evaluating media and talking about it with kids?

bones.png

27 January . Comment

SubCalc at the App Store

As folks who read this blog know, I have been pretty hard on Apple about their overzealous policing of the iPhone App Store. Today I have a very personal reason to acknowledge a job well done. Apple took only three days to review the app Alex and I submitted on 1/25. Today SubCalc became a free app on the App Store.

SubCalc is an app to help convenors of precinct caucuses and conventions in Minnesota. The Minnesota Democratic Farmer Labor (DFL) party uses a wonderful, but bit arcane, “walking subcaucus” process that is simple enough to do, but rather difficult to tabulate.

This app calculates the number of delegates each subcaucus gets when you enter the total number of delegates your precinct or convention is allowed and how many people are in each subcaucus. The rules it follows appeared on page 4 of the DFL 2010-2011 Official Call, including the proper treatment of remainders. It makes the math involved in a walking subcaucus disappear.

The app could be used to facilitate a “walking subcaucus” or “proportional representation” system for any group.

If you don’t have an iPhone, try the “web app” version of this subcaucus calculator for at http://www.sd64dfl.org/sub/. But if you do have an iPhone or iPod Touch (or iPad!) please give SubCalc a spin!

subcalc.png

27 January . Comment

Pondering the iPad

Apple made it’s big announcement today. Personally, I think it is a home run, particularly the pricing. But my brother disagrees. I’ve used his criticism to spur my thinking on this newest venture from Apple. If you want to dig in, read on!

ipad.png
Read the rest of this entry »

26 January . Comment

51 is a majority, use it or lose it

Are you as frustrated as I am at the timidity of Democrats in Washington? We act as if it takes 60 votes in the Senate to do anything. The Senate! Already an undemocratic institution (Wyoming == California, I don’t think so), has been made even more ineffective by our readiness to cave to filibusters that don’t even happen.

51 is a majority! And we have way more than 51 votes in the Senate. Let the Republicans talk for days on end if they want to block legislation. We should be making law! We have the votes. If someone wants to filibuster, make them get up and do the deed.

So I say, 51 is a majority, use it or lose it. If we stay timid, we will get what we deserve come November. Democrats have to be ready to make sausage, to compromise, but we must also get things done.

I’ve set up a little shop at CafePress with the message: 51 is a majority, use it or lose it.

Pick something up there if you agree. Pass it along. Tweet, blog, talk to your friends, call your Congresspeople, and call your Senators or Senator-wanna-bees. Make sure they know you expect courage and progress.

51useit-long-360.png

21 January . Comment

Plea for (gulp) the Senate bill

I just called Betty McCollum’s DC office and asked where she stood on passing the Senate plan. I was shocked that the office could not articulate a position on this. I can understand “yes,” I can understand “no,” but I can’t understand a leader sitting on her hands and waiting for more input. This is a crisis time and the outlines of the crisis have been evident for over a week. I’m afraid this wishy-washy response left me feeling like my congressperson is weak and ineffectual.

After this past year of wrangling back and forth, I find myself urging my representative to hold their nose and vote for the Senate bill. And not only vote, but lobby her on-the-fence colleagues HARD to do the same. Yes, I hate what the Senate did, I can’t stand, especially, the abortion provisions, the Nevada deal, and much more of the mess they made. But we have worked too hard and fought too many special interests to let this moment pass by. Democrats have everything they need to turn ashes into victory here. As bad as the Senate bill is, it is not “toxic.” That notion is poison being fed to the Hill from the right. It is, in fact, antidote. Passing a bill, even the Senate bill, is the only way to wake up the public to what has been good in this fight all along. Once it is a done deal, we can wake people up to all the positive things that are in the bill (yes, even in the Senate bill). Democrats gain nothing by letting the moment pass, all the real toxins, the negative thumping of the right wing, remains our baggage if we cave in now. The only way to refute lies is with demonstration, and we can only demonstrate with action, and the only path of action left is the Senate bill.

I know you are not in a position to carry the water on this. But you are all I’ve got. You can call your representative now, during most important week of the year that was and the year to come, and ask them where they stand. This will define Democrats. Governing is not about getting everything you want, it is about compromise. Can the Democrats govern? We have majorities in House and Senate and we have the White House. There is nobody else to blame. Can we govern? Can we compromise? Can we make sausage? Now we find out. Today. This week.

(Not sure who to call? Check with OpenCongress.)

hostpital.jpg

21 January . Comment

Bumptop

A few years ago I saw a TED demo video about BumpTop, a prototype 3D desktop designed for pen interaction. Now this prototype has grown into a Mac desktop environment called BumpTop. (There is a Windows version too.) Now it is time to see how much the product can live up to the presentation.

bumptop.jpg

14 January . Comment

FFR: Web hosts

A great thread on the Code4Lib list gives shoutouts to a number of web hosting services. Every few years I take a look at this market, so I wanted to remember to look at these in the future: Heroku (for Ruby), Slicehost (now owned by RackSpace), Linode (founded in 2003), WiredTree (noted for Drupal), DreamHost (which I’ve used too), and Sonic (run by geeks).

Screen shot 2010-01-14 at 7.52.31 PM.png

Eric Celeste / Saint Paul, Minnesota / 651.323.2009 / efc@clst.org