May 11, 2007

Making a Friendly Multiuser Rails Database Configuration Files

Many people and sites recommend not checking in your database.yml file directly in the subversion repository but instead check in a database.example.yml file that each developer is responsible for modifying themselves. The reason for this is because if other developers are working on the project at the same time you will both end up clobbering the file as one person changes the information to match their machine and you change yours back to match your machine.

Fortunately the database.yml (along with all the other rails config files) can contain code in them. This makes is possible to write this:

development:
adapter: postgresql
database: critic_development
username: <%= ENV['USER'] %>

test:
adapter: postgresql
database: critic_test
username: <%= ENV['USER'] %>

production:
adapter: postgresql
database: critic
username: deploy

For development and test configurations we use a local database that runs on our local development box with the username we logged in with but for the production server it runs as the 'deploy' user.

There is no need for passwords because the database servers are configured to not accept connections from remote sources.

For our small development team we find this solution works great and there is no need to special case our deployment to the production server by having a step to copy the production database.yml file. It may not work in some cases but for small development teams this might make your life a bit easier.

Labels: , ,

May 4, 2007

A Portable Rails Development Environment

Tony being the 'biz guy' just has to have his Windows Office Suite and thus any work he does on the site is done from Windows.

Our site is built using Subversion, Ruby, Rails and PostgreSQL. All of these work on Windows but none of them are first class citizens. We did get him setup using the various installers but it wasn't easy and took some time.

When I got the IM that he got a fresh laptop and needed his development environment setup again I didn't reply for 3 days. After that I got the idea of having him use an Ubuntu install on the free VMWare player. This way we could setup a complete development environment once and he could move it to any machine he wanted.

We still needed to setup a working Rails stack on Ubuntu but with there are various good resources on how to do that. The free PeepCode screencast (download the free preview for the server setup video) would be my first choice if I was doing it from scratch.

Once you get your virtual server running on your desktop you still have one more item to take care of before you can use your Windows tools for doing development. That is mounting your home folder from your virtual server to a drive letter in Windows. There is a fantastic piece of software called SFtpDrive which lets you do just that. It isn't free but it comes with a great 6 week trial period which gives you plenty of time to decide if it's worth it.

So there you have it. A first class development environment for doing Rails development under Windows. You get the power of Linux with the familiarity of Windows.

(Disclaimer: I don't have any personal interest in these products. I've used them and have found them to be high quality and useful tools.)

Labels: ,

April 13, 2007

Setting Up A Startup - It's So Easy Now!

I am constantly amazed at the high quality of many open source projects. I've worked on a number of them myself and can understand some of the reasons why people contribute free time to the projects but it still amazes me at the quality of some projects. This post gives you a general idea of all the tools we used to create our startup.

When we built ProductCritic we took advantage of as much open source software as we could to reduce our upfront costs.

As mentioned in an earlier post the site runs a virtual private server. It's running Ubuntu Server using Lighttpd as the frontend webserver and FastCGI to run the Rails applications. Eventually this will be upgraded to use Mongrel and possibly Apache but the current system is working fine in our environment and I see no reasons to change it at the present.

We are using PostgreSQL as the database server for no other reason than I prefer it to MySQL. For the type of application that ProductCritic is, (Digital Camera Reviews) either database server would be fine.

Subversion was used as our revision control system for code. A custom script runs every night on the server to backup the Subversion repository, PostgreSQL database and uploaded files. These are then downloaded to my personal server. If our server vanished we would be up and running in a few hours on a new server with the only the data of the current day being lost.

The site is deployed using Capistrano that uses a custom script I wrote for a previous site to manage the FastCGI processes.

Google Analytics is used to give us our stats.

The site was programmed using Ruby on Rails on a MacBook using TextMate and the Terminal.

We used a free Basecamp account to organize our task list and archive useful messages. During development I found that to be quite motivating in checking off our long lists of tasks and seeing them completed. We used a Writeboard to compose our launch announcement which worked out quite well as a number of people collaborated on that document.

It really is very easy (and inexpensive) to create a Startup on the Internet now. Focus on your great idea, gather some friends (or do it yourself) and go for it!

Labels: ,

March 30, 2007

Top 6 Resources To Learn Ruby On Rails

In a previous post, we discussed why we are using Ruby On Rails to develop ProductCritic. We're not saying it's the best framework since sliced bread (nothing ever is) but it's fairly easy to learn if you're interested.

With Rail's growing user base, the resources for learning the framework are certainly growing. The following resources are what I am currently considering the best locations of information.

1) Free Original Screencasts

Three free movies that give a great overview and show what the framework can do. Watch them through at full speed to be entertained but then go through them and follow along with your own editor to rebuild the applications yourself.

2) Agile Web Development with Rails, 2nd Edition

When just starting out I found it useful to have the print book but it's also available in PDF as well. This book brings together all the components in building an application is really worth the money. It's been recently revised for 1.2 so it should have a reasonable shelf life.

3) The Ruby Way, 2nd Edition

This book provides a huge number of Ruby idioms and examples that I find really useful for learning the "ruby way" of completing tasks. I came from a C++/C# background and found a number of ruby semantics a bit strange at first, specifically blocks. Since the Ruby language allows for completing tasks in any number of ways I like this book to see what the current accepted methods are for certain tasks.

4) Jamis Buck's Blog

Jamis Buck is a core contributor to Rails and employee of 37signals. Out of all the blogs on the net about technical aspects of Rails I find his writing the most interesting and easiest to understand. He is also quite prolific churning out good content at regular intervals.

He also created the Capistrano deployment tool and provides a lot of insight into the tool and deployment in general which is useful.

5) PeepCode Screencasts

These screencasts are very high quality at a very good price. It's like having a veteran rails developer mentor you on a topic that would be rather hard to document in a book. I found the RESTful Rails and Test-First Development for Rails the ones the most useful so far but all of them have been very useful.

6) Programming Ruby, 2nd Edition

Known as the "Pick Axe" because of the cover image this is a great resource and reference for the Ruby Language. I find the Ruby Way more useful for learning how to do a specific task but if I want to understand all the details of the language I refer to this book.

This post brought to you by:
If you love to learn, have you ever considered earning your online degree? If you love learning, sign online and find out how easy it is to further your education with an online degree. Whether you are interested in business management, engineering, or medical billing, there is sure to be a career path you would like to choose!

Labels: , , , ,

March 23, 2007

Who Else Wants To Use PostgresSQL Instead Of MySQL?

In a previous post I mentioned that we use PostgreSQL as our database server. Common sense might indicate that we use MySQL as that is what the core team is using and what would probably be considered to be the defacto standard for Rails development.

So why are we using PostgreSQL?

Probably the biggest reason we use PostgresSQL is the simplest...I like it more than MySQL. This is one of the main reasons why we picked Rails as our development platform. When all things are equal, pick the one that is more enjoyable to use as you're going to be spending lots of time with it and it helps with motivation during those long hours of a startup.

Both databases are perfectly capable and I've used both on live sites but I've always found MySQL to be harder to use from the command line. This may be because I don't know how to use all the features but that's is part of the problem isn't it? Learning PostgreSQL on the command line was very easy and intuitive, MySQL isn't.

The other reason I like PostgreSQL over MySQL is that it's a completely free and open project. With MySQL it feels like it's a commercial project from a business that makes the code available (which it is). There is nothing wrong with this but I feel more comfortable knowing that PostgreSQL ownership is more distributed and that there is no large single point of failure in the project.

If you are picking based on technical issues you'll find a holy war that runs deep for many years about both projects. It seems to boil down that MySQL may be a bit faster but PostgreSQL is more reliable. With the latest revisions of each I'm not convinced that either is true. MySQL seems reliable enough for the millions of sites using it and PostgreSQL is fast enough for our site.

For ProductCritic, either database would have been fine so we picked the database that we find is more enjoyable to work with.

This post brought to you by:
Do you love computers? If you are looking for more information on Buying a brand New Computer, sign online. Computer technology changes constantly. If you want to stay on top of the Computer Operating Systems, do your research. If you are interested, you can check out the Computer based Buying Guide!

Labels: , , ,

February 26, 2007

Build A Website Using Ruby On Rails That You Can Be Proud Of

ProductCritic is developed with the Ruby on Rails framework. This entry will give some insight on how this came to be.

My experience with web apps started with ASP and later onto ASP.NET. I found ASP.NET a huge improvement over ASP but after working on a few sites I still found it lacking.

Specifically one thing ASP.NET does not have good support for is nice URLs. I'm sure there are ways to do it but I never found a good solution to removing those ugly .aspx page extensions. Also, the page/form centric model that ASP.NET uses is a bad design for medium to large sites I find. No matter how hard I try I've always found my ASP.NET based sites always becoming a bit of a mess if they take off in size. There were many other problems and things I just didn't like about ASP.NET so about a year and a half ago I began looking for an alternative.

I got interested in working with Ruby on Rails after seeing the original screencast. I'll never forget thinking "who is that crazy danish guy yelling 'whoops' every few minutes as he cranks out features on his demo app?" What impressed me the most was when I spent the time to duplicate what he was doing in the screencast and realized that this guy knew what he wanted when he built the framework. Pretty URLs? Yup. Organized directory structure? Yup. Support for automated tests? Yup. Database persistence layer without a huge amount of setup code needed? Yup. The feature list was just perfect except for one thing...I didn't know Ruby. I had heard of it before but never used it and coming from a C++/C# background it sure looked like Perl to me sometimes.

Luckily though, while Ruby can be as hard to read as Perl it doesn't have to be and if written well can be extremely easy to read. Once you understand blocks you'll be fine. I like to compare understanding blocks to understanding pointers in C/C++. The first time you see them they are odd but once you get the 'aha' everything starts to make sense.

After building a number of Rails sites and working with Ruby for more than a year I have become quite found of the language and the Rails framework had proven itself on a number of production sites in the past. So when it came time to pick a framework for ProductCritic there really wasn't any question that we would use Rails.

That said, there are a number of very good and sometimes overlooked features on Rails that are worthwhile to point out:
  • Leverage an experienced web developer. DHH and the Rails Core team have a lot more experience than I do in web development. Using there framework allows me to leverage their experience on my projects.
  • Deployment. Capistrano, the deployment tool that works with Rails is amazing for getting your site onto a production server in a safe reproducible manner.
  • Free and open. Why pay for something when an equal or better solution exists?
  • Fast enough. I've heard lots of stories of Ruby being slow but in all my tests and on all my sites it's never been an issue.
There are lots of web development frameworks that we could have used to build ProductCritic. We picked Ruby on Rails ultimately because I enjoy working with it. Picking what makes the development staff happy is ultimately the best deciding factor to use when all other things are equal. Happy developers are productive developers.

Labels: , , ,

February 19, 2007

Get Full Referral URL's Despite Using Analytics

As I've mentioned in previous posts, I'm completely addicted to the stats generated by ProductCritic. Maybe it's just the fact that we gain knowledge on areas we need to tweak for the site (and we're tweaking on an almost daily basis).

Besides the server logs (which I don't check all the time), we use Google Analytics as our main source of information about visits to the site. Analytics provides a large amount of data and first time users of this tool can easily find themselves overwhelmed.

Although I look at almost all areas of Analytics from time to time, I mainly focus my daily stats fix on two areas. The first is Visitor Segment Performance/Referring Source. I want to know where visitors to ProductCritic are coming from. It's been quite useful as we've immediately been able to determine when someone links to ProductCritic and where that link exists.


The second area that I use in Analytics is Search Engine Marketing/CPC vs Organic Conversion. Although we currently don't use Adwords, this section is still extremely useful for us as it provides us with the ability to see what keywords people are using to find ProductCritic via searches (hence "Organic Convesion"). Since we get a majority of our traffic from search engines, the information here gives us some indication about whether we should concentrate more effort on aggregating reviews for digital cameras, camcorders, or cell phones.

So, what does all this have to do with getting full referral URL's? Well, that's one thing that Google Analytics does NOT do well. For example, last week, we noticed a sharp spike of referrals from the forums at dpreview.com. Although Analytics showed us the referrals, we couldn't tell EXACTLY where they came from (only that they came from forums.dpreview.com). We could check the server logs, but if you don't have access to them, there's an easier way.....sign on and use HitTail.com. It's an awesome free service and although most people use it primarily for keyword suggestions, the tool gives you every referral URL in full detail. Since it also does this for searches, you can click on the links that HitTail.com gives you to exactly reproduce the searches that people use (including ones from localized versions of Google).

Note that we're not affiliated in any way with HitTail.com....it's just a great FREE tool that everyone who's serious about tweaking their site for optimal revenue should use.


This post brought to you by:
If you spend all of your time on the computer, are you up to date on the best computer Operating Systems? If you need more information on buying a computer, check out the best Computer Buying online Guide! No matter if you want a new computer, or you are just interested in buying Computer used Parts Online, the internet can help!

Labels: , , , , ,

February 9, 2007

Startup Lessons From ProductCritic - Why We Run Linux

This is part two of Startup Lessons from ProductCritic. Part One can be found here.

Deciding on the operating system that will host your application has a huge ripple down effect on the rest of your system. There is effectively two options you can choose. Windows or not-Windows which is effectively Linux but not always.

Choosing Windows will almost certainly lead to IIS, SQLServer, and C#/VB.NET and choosing Linux will almost certainly lead to Apache, MySQL/PostgreSQL, Perl/PHP/Python/Ruby. Yes, you can run ASP.NET under Mono and you can run Ruby on Rails under Windows but doing so I find is an uphill battle. If there is anything that I have learned is that working in the preferred environment makes life a lot easier.

The preferred environment means using the software in the same environment that it was built in. If you work in QA this is a bad idea because little bugs will go unnoticed but as a user it makes things far easier.

Luckily, both OS's have platforms for their preferred environment that are equally capable. There are different costs and skills associated with Windows and Linux but neither will prevent or enable you to be successful. Picking the OS is not a make or break decision.

This means that choosing the OS is probably going to come down to which is the preferred environment for the platform and probably even more likely which OS the developers like more.

For ProductCritic we used Ruby on Rails as the platform. Since Linux is the preferred environment for Rails, the OS decision was pretty much made for us, but there were a number of other reason why I think Linux is a superior platform for startup web sites:

* free and open, why buy an OS when one is free?
* reliable and lightweight, can run on small servers and slices, great uptime
* low cost Virtual Private Hosting is available

These are totally subjective and any strong opinionated Windows developer will come up with an equally favorable list for Windows. Hence the factor of developer preference. Ultimately we picked Linux because I like it more and that should make sense to anyone!

This post brought to you by:
No matter what type of computer you use, it's always important to stay up to date on the best computer Operating Systems. If you are in the market for a new computer, do you know what you want? Check out the online computer Buying Guide to see what computer will best suit your needs. No matter if you need a new computer, or just want Computer used Parts Online, the internet can help!

Labels: , , ,

February 6, 2007

Startup Lessons From ProductCritic - Save Server Costs

We thought it would be interesting to share some of the technical decisions we made with creating ProductCritic. In this first of a series we talk about the hardware running the site.

ProductCritic runs on its own VPS (Virtual Private Server) supplied by SliceHost. A VPS allows a single machine to emulate multiple machines. What this allows is a service provider like SliceHost to own a high end server and then slice it down into any number of smaller less powerful servers and then rent those out to customers.

It's a really great because you get your own rock solid piece of (virtual) hardware running in a secure data center with fast network connections at a very reasonable cost. Since you own the entire slice you can install anything you want on it. You also don't have to worry about anybody else wrecking the server when they install something because only you have access to it. Since the service provider is running very little software itself not much every changes on the server causing a crash or reboot. The result is great uptime as can be seen here:
  % uptime
16:55:55 up 76 days, 20:47, 0 users, load average: 0.08, 0.02, 0.01
But one of the greatest reasons to use a VPS is because it allows you to grow your hardware needs as your site grows. Instead of investing thousands into your own dedicated server and that is basically just going to sit idle 99% of the time you rent a slice of the size needed for your site. This is less expensive, more flexible and very cost effective. Zero upfront costs and very low monthly costs. ProductCritic is running on the smallest slice available and as you can see from uptime report has a very low load. I find that a sustained load > 1.0 results in slower response times.

Disclaimer: We have no affiliation with SliceHost other than being a happy customer. If you signup with them and want to send us some love enter 'gerry_shaw@yahoo.com' in the referral email field. We'll get a credit but it won't cost you anything.

This post brought to you by:
Who doesn't love new technology? If you are on the hunt fornew computer Parts Online, do your research. Whether you're interested in Buying a brand New Computer or you want to just find Discount Computer Parts, the internet is your best pick for all of your computer needs!

Labels: , , ,