Archive for January, 2008

It’s going to be a great year for me because

Wednesday, January 2nd, 2008

…the first game of cell phone solitare I played, Oh yeah, i owned it.

I’m talking about CASCADING KINGS here.

This is the mail that I sent to Rails-list which describes my issues around the Rails scaffolding in Rails 2.0. Extensive debugging information can be found in my diagnostic research post.


Hello,

I’ve read the (many) re-posts about problems around scaffolding in Rails 2.0 and have followed a number of tutorials and fully understand “how to scaffold” from a technical perspective, but I don’t understand the mindset of how to use the new scaffolding. It seems like a productivity- / agility- regress and I’m thinking I may have failed to properly grok the new setup. In the interest of full disclosure, I’m coming back to Rails after being in other toolkits for about 9 months.

Thanks to the intrepid work of Sean Lynch at ( http://fairleads.blogspot.com/2007/12/rails-20-and-scaffolding-step-by-step.html ) I found a tutorial that would familiarize me with the raw “how to scaffold” material.

I followed his tutorial’s step of:

“ruby script/generate scaffold Movie”

Great! From that point I filled in the “columns” in the migration as I had done in Rails 1.x. All I should need to do is run “rake db:migrate” and try adding a new record via the dynamically-created view.

When I started the server and navigated localhost:3000/movies I had the “create new” button. When I pushed that button there were no text widgets to enter despite having defined the columns that corresponded to said widgets having been added to the migration ( I have a lengthy blog post about how my diagnostics went, for anyone else’s edification ). In short the scaffold that had been created knew nothing of the columns I had added in the migration and, as such, the ‘new’ view had no widgets.

This struck me as well, wrong. On Sean’s post another user confirms the same experience. I have tried it with sqlite3 / mysql / postgres connectors.

Research showed that the scaffold had remained static relative to the time that I had done the original aenemic invocation. Per “script/generate scaffold —help”:

./script/generate scaffold post` # no attributes, view will be anemic

To fix this I had to re-issue the script/generate command with all the attributes in “final draft” mode ( “script/generate scaffold movie title:string text:description one_sheet_url:string” ) and then over-write the old templates ( output stored below, for legibility, Fig. 1).

The solution implies:

  • You have to get the script/generate command’s “attributes” arguments perfect at time of creation OR
  • You do this overwriting thing that I describe below.

As I recall Rails 1.x’s dynamic scaffolding allowed us to use a scaffold flexibly strictly based on migrations and rake db:migrate. This flexibility allowed us to “sketch” ideas very rapidly. Or is it considered a “Good Thing” that you get a “perfected” “generate scaffold” command at some point? If so, what’s the reasoning? Am I missing some sort of rake command that “refreshes” the scaffold templates?

Based on the comments at Sean’s site and some of the questions in the comments to DHH’s Rails 2. announcement I think there are others grappling with this quandry as well. Can anyone help?

Steven

(more…)

I decided to spend some of my Christmas break taking a look at Ruby on Rails again and trying to get an application together under this application stack. Since I last looked at Rails, it had crossed the 1.x to 2.x version marker and several changes manifested. For someone trying to follow the 1.x tutorials or the canonical reference book Agile Web Development With Rails, one doesn’t make very much progress before the changes with respect to scaffolding bite one. One may need a bit of a tutorial on Rails 2.x scaffolding before being “pretty close” to training documentation. An excellent tutorial for this content was found at [Fairleads][fl].

Yet as I followed this through, I found myself stymied by the same error reported by “James”

Thanks now I easily understand how scaffolding changed in 2.0.

But I still have a problem when I followed the tutorial everything went fine but i am not presented with any sort of fields to enter information.

And when i add stuff to the database by hand and I list from within the scaffold I am not getting the information that is entered into the database I am just getting a blank entry.

At first I thought my problem was that I was trying to use a PostgreSQL back end, or perhaps it was because I was using MySQL, etc. But nevertheless I still ran into the same problem no matter which db back-end I used.

I then found another tutorial at [SapphireSteel][ss]. Curiously, this worked ( the db back end was sqlite3 ). This tutorial is meant to show off the Sapphire Steel product, but Huw, the author, has added, graciously, a “here’s what Rails is doing on the back end” translation for each step that his product automates.

With these data points my working hypothesis was this:

  • Use SQLite3
  • Follow Huw’s instructions, which use a more specialized invocation of “script/generate scaffold” ( control )
  • Duplicate these instructions using a more primitive invocation of “script-generate scaffold” that’s more familiar ( experiment )

    (more…)

Back in ATX, Dei gratia, and New Year’s

Tuesday, January 1st, 2008

We returned home from SNA on the evening of the 29th after having spent the morning sleeping in and heading out to Laguna Beach. Laguna is a special place for Lauren and I, it’s the first beach she ever took me to in her home-area and returning to that spot always feels like a ritual: we re-enact our walk, see the same immutable motley of beach-side attractions and linger across the sands with the roar of the Pacific to our right.

It was a slightly cloudy day and, thanks to the winds, it stayed a good bit cooler than we would generally like, but a cold day by the beach beats a bad day just about anywhere.

We also had a chance to take part in one of our most favorite guilty Californian pleasures: Carl’s Junior. We are both great fans of the Western Bacon Cheeseburger ( approximate ).

Owing to the early evening departure, we wound up getting back to a chilly Austin at about 10 in the evening after a very speedy (thank you, American Airlines!) flight that clocked just over 2 hours traveling time. After claiming bags and car, we headed for a late night breakfast taco at Whataburger and arrived home about midnight and promptly crashed out.

( I must be hungry as I'm writing this...)

Since that time it’s been more time recovering from my cold, a day of work, some movies, unpacking, and washing.

I’ve also been working on understanding an issue that’s bitten several people with respect to Rails Scaffolding, that lengthy post will appear shortly. I figure I could share my diagnostics and thought processes with other baffled Googlers.

Last night, however, was a wonderful NYE. We went to Ararat Rising New Years Eve which we found, yet again, by do512.

On the way south we stopped by the fine Spec’s and picked up a bottle of Veuve Cliquot and some ice for among the many appellations appropriate to this event, ‘unlicensed’ was also a fitting attribute.

As we had so utterly procrastinated, we were unable to get dinner tickets for the Ararat event and were invited to come back at 10:30 for the dancing / toast event. For the 2nd year in a row, we punted and wound up having a wonderful dinner for two at Hyde Park Bar and Grill South.

It was great to have a quiet, connected dinner between just the two of us: it almost made you think you were out of the holiday season as there was no talk of travel, presents, family, trees, decorations, etc. It was almost like re-discovering one another yet again.

Thereafter we returned to the Mercury Hall to see a belly dancing performance based on “The 4 Elements”.

IMG_0668

IMG_0673

Thereafter we retired to the outdoors to watch the astounding Sangre del Sol group perform an arresting and exothermic display.

The dancing ended in time for champagne and wishing a happy 2008 and with this dancing and merriment was underway. It was a highlight to pop the VC and share it with some fine folks we met during the evening’s processions. We decided to head out before the clock tolled two and made it home without any surprises.

And that’s in folks: Happy New Year