Started stepping through OnLAMP’s Ruby on Rails tutorial this evening. A lot of foreign concepts — brave new world compared to PHP development. Then, suddenly, on page 3, I added a field to my database and wham! — that field was added to all relevant pages of my application. A text entry field for the edit, create, and update pages, and an appropriate column on the display pages. Number of lines of code added to the application: Zero the Hero. Change that field’s position in the database table, and its placement throughout the application changes automatically. The application automagically models itself after the form of the database. The dataset is the model for the application.
Granted, we’re just talking about the scaffolding here, but when I stopped to think of the number of files I need to modify in a PHP application to get the same effect (and how many times I’ve needed to wheedle through exactly that kind of repetitive work), just had to roll my chair back from the desk and take a deep breath. This has some pretty stunning ramifications.
Also amazing how much mileage Rails gets out of simple naming conventions. Name a model class Recipe and it will automatically map to a corresponding database “recipes” (the pluralization translation happens automatically). Stick to the conventions, and the need to write database CRUD (create, read, update, delete) code goes away. And elegant URLs are totally automatic too.
Newbie steps, but all of a sudden I’m “getting” what all the fuss is about.
Serendipity.
Just these days my wife has started playing with Ruby & Ruby-on-Rails, and she made the similar discoveries.
…I am so not looking forward to get back to work and continue writing Java members and accessors and metadata and configuration XML just so that I can read a column from a database table.
The frustrating thing is that, while the language may be easy develop for, getting it neatly installed and cooperating with a standard apache environment is a total PITA. I’ve spent hours installing gems, mysql bindings, fcgi extensions, modifying httpd.conf, tweaking paths and permissions, etc. Each Rails app has its own little lighthttpd (WebRick) server, which works quite nicely for development. But for production, you want to be able to drop things into place like you do with PHP or Perl and have things just work — and that’s been a major pain in the neck so far (you have to ask yourself *why* each Rails app has its own server script). There’s a ton of documentation out there on how to get it working with apache through mod_ruby or .fcgi, but seemingly no standardized method yet. It’s as if the language is taking off but the integration with standard hosting environments has a lot of catching up to do. All a long way of explaining why I haven’t yet announced Rails integration on Birdhouse.
Hi Scot,
Look at SCGI instead of FCGI and lighttpd instead of Apache.
For the Mac, Locomotive provides a totally self-contained Rails environment out of the box…
-Tao.
p.s. have a look at my latest post on blog.taospace.com and see the contrast :-).
Thanks for the tip Tao. This does look intriguing. Unfortunately, found this comment out there: “SCGI would be nice, but unfortunately, it doesn’t provide a dynamic configuration for Apache. So, we’d have to manually add your application every time you wanted to create a new one. I’d much rather have it create-able in the control panel, to be honest.” That’s exactly the problem I’m facing… But will look into this after vacation.
Personally, I am finding RoR to be an exercise in futility. There is no good documentation beyond 457475473 copycat tutorials that show using scaffold and a single table. Useless drivel. Or, you can wade through the API which really isn’t much better in getting up to speed.
For instance, I have related two tables with the belongs_to and has_many but I cannot access the data from the “belonging” table. No matter what wacko ruby syntax construct I attempt, or an hour searching on google for ANY clue, I cannot do anything with it.
The rigid data model ( welding the whole thing to the pretty much mandated simple schema ) is really not going to cut it for me. Even if you can find a way, who would use this for a site larger than 20 pages?
Rapid development? I beg to differ. It’s like wearing a straitjacket upside down and backwards. Give me Spring/Hibernate any day of the week. JUst my opinion of course
Interesting comment, Unhappy. Though I haven’t gotten very deep into it, I have to say I sense much the same thing. A lot of hype surrounding the ease of getting a Rails project off the ground, a lot less hype over the ease of continued development. The “more than one way to do it” philosophy of perl and to a lesser extent PHP have served them very well, even though it can lead to some chaos. In chaos is flexibility.