Archive for the ‘rails’ Category

Summer of Rails

Sunday, September 21st, 2008

I’ve now worked on three different Rails applications. One of them was from scratch, the other two I took over from someone else. The thing I like most about Rails is Active Record – it just works and it is easy to use – even for existing databases (although it takes a bit more work to specify the mappings).

I have a project coming up that would probably be a great Seaside candidate. The database has to be postgresql (according to the client). There is a native cocoa component – I’ll probably give BaseTen a try. For the web component, the obvious candidates are Rails (although I don’t know the state of Rails with PG – only mysql), and Seaside/Glorp – but I need to use Glorp to work like Active Record since the DB will be the master source of record for the schema.

Sadly, it doesn’t look like Glorp’s ActiveRecord on Squeak is ready for prime time, I might have to kind of finish that implementation.

Rails is Magic

Thursday, May 22nd, 2008

And I hate magic. First, I confess that I probably still don’t have a full command of all ruby’s features – I’m just getting the hang of mixins and some of the wacky compositional capabilities.

I’ve just deployed my first soup to nuts rails application. Well, nearly. It certainly starts fast. Generate ActiveRecord classes for your tables using scripts and you’re off and doing basic CRUD.

However, its the little things that made the experience less than satisfactory. First – the changes in behavior moving from development to deployment were nerve wracking. I have rails running under apache on my laptop, no problem. On my production server, I cannot get byte one to come out of rails. Webrick works fine. Mongrel works. Rails cgi produces no errors, and no output. Even apache logs are totally silent. I don’t get it. For now it is running under mongrel – but I’ll have to put that behind apache and front it using modproxy. Irritating as hell.

Second, I set up memcachedкомпютри втора употреба on the advice of friends and was going to use it for my session cache. But it turns out that objects don’t get saved in the memcached – apparently you can only store plist kinds of structures. Objects get dropped. I spent several hours beating my head against this using the usual hammer for this nail – require_dependency. However, after listing every blessed model class as a dependency, it was still dropping a collection of objects. Back to the file based session cache.

Another thing that drove me nuts is all the magic values you can’t use for attribute names. I inherited this database and admittedly a bunch of columns and tables are stupidly named – however I kept running into problems with collisions with ActiveRecord extensions.

Another thing – camel vs underbar lowercase. You generally specify relationships as lower case names, that ActiveRecord uses to infer a class name. For instance, you specify the relationship as purchase_order and it figures you have a class PurchaseOrder that keeps its data in a table called purchase_orders with a foreign key purchase_order_id. This can all be overridden, but understanding which form to use where got pretty trying.

Reciprocal relationships – at some level of circularity, ActiveRecord falls over with stack level too deep on save. It isn’t even a very complex graph that does it in. It became necessary to remove a bunch of back references to get a save to work properly.

Overall, I’d say towards the end I spent more time debugging magic gone awry than I did building application functionality. So I have to chalk it up as a real learning experience, but not one I’m looking to repeat anytime soon. The lack of decent debugging facilities was really crippling – especially coming from seaside. ActiveRecord is cool, but it isn’t trouble free. Doing basic inheritance was a huge exercise in wackiness I’m not eager to repeat. If I hadn’t had a big old mysql database to build on top of, I probably would have used seaside instead.

So enough slamming – its not all bad. One thing that helped a LOT was the discovery of ActiveScaffold AS is AMAZING! I was able to throw together a coherent admin interface with it very quickly – its customization options are very powerful, and in the end I think the back office app will be about 80% AS and 20% task oriented workflow. That’s brilliant. A data driven sensible ajax interface almost instantly. Very cool.

I may do more ruby apps, there are some seriously powerful go-fast kinds of technologies, but much of the time savings this go-round was lost to flukey behavior that changed from environment to environment, and really lame debugging tools.

Rails is definitely a very mixed bag.

Quick Ruby Thoughts

Tuesday, April 29th, 2008

I have to say I’m liking a lot about Rails. Ruby, not so much. Probably the most annoying thing about Ruby is the syntax. It is MUCH too complicated and after working with it for awhile, I still don’t quite understand all the rules. Things that puzzle me:

dot notation vs non-dot notation. When to use which?

collection.select {| x | x > 5 }

vs

collection select {|x | x > 5}

they both seem to work. Also, use of parens around argument lists – also seems to be optional. Two different block definition syntaxes is also annoying.

Less syntax would be most welcome.

Hoppin’ on the Rails

Friday, April 4th, 2008

I’ve got two new clients – on is taking over expansion of an existing Ruby on Rails application. The other is the replacement of the application I wrote in the previous article. I want to stick a new codebase on the existing database. Since rails excels at CRUD and I’m short on bandwidth and hand-off-ability is a concern with the new development, I’m going to use rails for that one too.

I mean, I can only learn so many frameworks at once. So here we go – working through Agile Web Development with Ruby on Rails.

Looking for work again

Monday, March 3rd, 2008

I’ve been doing a lot of PHP lately – shopping cart integration, web service clients, lots of ecommerce stuff. But I’m coming to the end of these projects and am looking for new challenges. Got a project or position that I can do remotely? Drop me a line.

Ruby on Rails Shopping Cart Engine

Sunday, March 19th, 2006

Substruct is a free shopping cart implementation for Ruby on Rails. For people building ecommerce sites, this nice vanilla plugin will save a big chunk of time. It includes:

  • A simple content management system with blogging capabilities
    • Manage your entire site from the web
  • A simple shopping cart that’s tied into Authorize.net (must have an account)
    • Live real-time shipping rate calculation via FedEx? (must have an account)
    • More payment processors like Paypal and 2CheckOut coming soon
  • Product and order management
  • A stunning administration interface
    • Create and maintain content
    • Create, maintain, void orders
    • Answer questions from your visitors

We seasiders need to get moving and do something similar.