I finally got Merb working with both gems and ActiveRecord plugins, and as usual have some thoughts to share.  The process has some real gotchas. In the end however I thing the Merb folk have gone in the right direction here.  In the mean time read on for some tips and hints as I try to port the Acts As Better Nested Set plugin from Rails working with Merb + ActiveRecord.

Read the rest of this entry »

If you head over to the main site, you can see the new interface for most of the pages.  It is an improvement, and it allows much more flexibility in presentation.  As soon as I get this darn nested set plugin working, we might start to see some actual content.  Wouldn’t that be cool!

Today was going to be so productive.  I had the whole day to work on AntaresTrader.  I have gotten almost noting done because I keep hitting snags.  This post is going to list how I solved some of them and ask for help on others

gem update –system => Nothing to update

RubyGems 1.2.0 has been out for some time and I have not been able to upgrade to it.  It just kept saying nothing to update. I thought it was just having a hard time getting out through the repositories, but it had been to long.  I hit google and found nothing obvious.  It took sifting through a number of forum posts to find the answer.  Here it is the solution:

sudo gem install rubygems-update -v 1.1.1

It appears that the gem that updates rubygems is usually included in a rubygems installation, but that the apt-get package is difficient in this regard.  Ubuntu users of Ruby should be aware of this problem.  Once this is done update the system as usual.

Read the rest of this entry »

I’ve gone through the somewhat troublesome process of moving all my different development boxes as well as the server to the new Migration format.  While I could now probably hack my way through it now, it ended up being easier to just delete the  database and migrate from the beginning.  This ended up being a good thing to do because it forced me to add migrations for a few early tables that I had just been getting out of the schema.rb file.Having gotten through this mess, I like the new format better, but I can instantly thing of a way to improve it.  First a little background. The assumption the the Rake script makes is that all migrations might depend on older (i.e. smaller numbered) ones.  When I back out a change, I potentially back out other changes that simply happened to be have been made in other branches in the interim.  Further, even the changes I made may not necessarily be dependent.  For example, at the beginning of a project, a lot of the migrations are just adding a new table.  They don’t depend on anything else.  Next come several migrations to add fields to existing tables.  They depend on the original table creation migration, but not on the intervening added tables. Finally as information gets moved around, some changes may depend on others in much more complex ways.

Read the rest of this entry »

When I switched from Rails to Merb for my Controller and View layers, I got the chance to explore some of the alternatives to the standard Rails packages.  I’m now using Haml from Hampton Catlin as my templating library, and Saas look like a good way to do CSS.  I’ve also gotten a chance to look at some of the other so called AJAX JavaScript Libraries.  In this post I’m going to look at some of the difference between Prototype, which is the rails default, and JQuerey, which of late has seen a lot of promotion from the unobtrusive javascript part of the world.

Read the rest of this entry »

Would anyone like to guess what the biggest impediment to switching to OpenOffice was for me?  Not the user interface, nor the need for compatibility, not even the mental inertia of learning a new system.  For me it was the lack of a decent spelling correction algorithm.  Let me be honest here.  I cannot spell well.  in the days before the magic of read underline, I would spend more time correcting the spelling mistakes in a paper then I would writing it.  First my parents, then my roommates and now my wife are incessantly bombarded with requests to spell words that I’m sure most of the USA learned to spell by the sixth grade.  So you can see that good spelling suggestion are important to me.

Read the rest of this entry »

When one has a programming challenge, it is comforting to find that other smarter people are arriving at the same solution. This was my experience today when I read Martin Fowler’s Bliki post about building web pages dynamically in segments. As much as we like to think that out pages are all about dynamic content, a vast majority of the page does not change. Most of the rest only changes rarely where time is measured in number of page views per change. Being able to cache as much information as possible as far form the origination source as possible is a huge scalability advantage. The problem becomes how to keep a number of different but relatively static elements on the same page. The answer that Mr. Fowler and I both came up with is to break the content up and retrieve it separately. Each piece can then be cached at the appropriate level.

Read the rest of this entry »

As I wrote before the long weekend, I now have users up and running.  There are many good User plug-ins and if I had it to do over again, I might seriously consider using one of them, but as usual with this project, I want to be able to tweak things so I rolled my own.  This contains some of the insight I got by doing so.

Read the rest of this entry »

Quick, go here and create a user.

A lot of the user functionality is working at the main site.  I’ll write a lot more about this when I get back from the weekend, but for now just go look around!

I’m almost ready to push out the next building block of antarestrader.com, that being the user interface.  Depending on whether I have to work today, it may be out before I leave for the long weekend.  This could be your last chance to add random content to the Help pages without having to give your name and e-mail first.

I have run into a bit of a hitch however.  I’ve inadverntently created a 1+n query.  On the index page for users I currently list all (2) users and hilight those who are logged in.  Being logged in means in this case having an entry in the logins tabel that has login hash, and does not have a logout time.  To the User model even has a function that checks for this using an appropriate find statment.  In the model I write ‘user.active_session?’ and use the result to change the class attribute of the enclosing html tag (haml rocks for this sort of thing).  Problem is every time I call ‘#active_session?’ I generate an sql query.  Forn users I will get 1+n hits on the database.  This is generally a bad thing

The question is should I fix it?  I tried using an include, but in ‘User.find(:all)’ but of course, that doesn’t fix the #active_session? method.  It also load the users entire login history which I don’t need.  To me the obvious solution is to write a custome SQL query that selects all the users fields plus a ‘count(`login`.`id`) as active_sessions’ and then dynamically overwrite the #active_session? method to check this for a value greater then zero.  This seems to me like a real hack however, and I wonder if it comes under the heading of premature optimization. (I wonder if datamapper’s eager loading would solve this?)

For the moment, I’m going to leave it as is with a big not to fix it in the future.  I want to finish pulling the embeded JavaScript out of the old Rails view code and make a slight rewrite on the user editing page before I put the code up.  Then I can have some fun retrofitting PL7 to take users and actually have something real up, but it is an interesting question to me about when to fix this obvious problem and to what length I should be willing to go to get it fixed.  Suggestions are always wecome in the comments, It may take me till tuesday to get them to clear spam however.

  • Stats

    Visits today: 12 | Top Post Sketch Programming: A Precursor to Test Driven Development