How to setup a Rails 3 app

I finally decided to give Rails 3 a spin after beta was released 20 days ago. In geek time, that’s being a late adopter. But first, a warning. I’ve read several posts about setting up Rails 3 and as of today, some of them are outdated already. Things are happening so fast that it is not impossible my setup becomes out of date too in just a matter of days.

Preconditions:

Yes, I removed all the gems in my laptop because I want to see clearly what’s happening in my setup. Also, I have tons of obsolete and unused gems that I figure it’s easier to remove them all.

quickie version

sudo gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n --no-rdoc --no-ri
sudo gem install rails --pre --no-rdoc --no-ri
rails mojo
cd mojo
sudo gem install sqlite3-ruby --no-rdoc --no-ri
rails server

Rails 3 requires ruby 1.8.7
I was using 1.8.6 and I guess there’s no harm in trying. After being coerced to upgrade ruby, I also upgraded rubygems to 1.3.6. This also means many gems need to be upgraded and/or rebuilt. Heck, I’ll just delete them :)

Unknown command bundle
If you got this error, you followed wycats’ post on setting up Rails 3. The correct command is ‘bundle install’

undefined method `directory’
If you got this error, you read wycats’ post but you didn’t read the 37th comment. wycats’ post is outdated.

‘bundle install’ fail
If bundle install becomes unresponsive, as was the case in all of my attempts, just skip it and install the gems yourself.  Ideally, all these gem install steps would be handled by bundle install but as I’ve said, it’s failing on me and I don’t know why.

These are the gems installed after this experiment:

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.0.beta)
actionpack (3.0.0.beta)
activemodel (3.0.0.beta)
activerecord (3.0.0.beta)
activeresource (3.0.0.beta)
activesupport (3.0.0.beta, 2.3.5)
arel (0.2.1)
builder (2.1.2)
bundler (0.9.7)
erubis (2.6.5)
i18n (0.3.3)
mail (2.1.3)
memcache-client (1.7.8)
mime-types (1.16)
rack (1.1.0)
rack-mount (0.6.0, 0.4.7)
rack-test (0.5.3)
rails (3.0.0.beta)
railties (3.0.0.beta)
rake (0.8.7)
sqlite3-ruby (1.2.5)
text-format (1.0.0)
text-hyphen (1.0.0)
thor (0.13.3)
tzinfo (0.3.16)
Share and Enjoy:
  • Digg
  • Facebook
  • StumbleUpon
  • TwitThis

How to read Google buzz updates in Ruby

require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'feedzirra'

profile_name = 'dave.winer'
page = Nokogiri::HTML(open("http://www.google.com/profiles/#{profile_name}"))

feed_url = page.search('//head/link[@type="application/atom+xml"]').first['href']
feed = Feedzirra::Feed.fetch_and_parse(feed_url)

puts feed.title
puts feed.url
puts feed.last_modified

feed.entries.each do |entry|
puts
puts "Title: #{entry.title}"
puts "Content"
puts entry.content
end

I can’t find the Activity Streams tag. Feedzirra could be filtering it but I haven’t look at it yet.

Share and Enjoy:
  • Digg
  • Facebook
  • StumbleUpon
  • TwitThis

25 secrets of lasting success

Be yourself. Do not pretend to be someone or something you are not. Your uniqueness will appeal to a certain segment of the market. These folks become your best fans and customers.

Following your passion – doing what you love – does not guarantee financial success. But not doing what you love guarantees a life of boredom and unhappiness. The trick is to find a niche where your passions and interests intersect with the needs of the market.

Learn a financially valuable skill so you can command a decent salary or (if you are self employed) a respectable fee.

Those workers and service providers who command top dollar either (a) perform a service that makes or saves their employer or client money or time, (b) have a skill for which the demand exceeds the supply, or (c) specialize in a narrow niche with little competition.

If you can earn a salary or generate a net income as a self-employed service professional or independent contractor of $200,000 a year or more, you won’t get rich. However, your life will be easier and you will be financially more secure than 95% of Americans.

Given the choice, have your children when you are young and possess the energy it takes to parent active youngsters.

Spend as much time as you can with your children when they are young and still want you, even if you must make sacrifices in your professional achievements to do so. This time passes quickly and once it’s gone, it’s gone for good.

Strive to achieve a liquid net worth of at least $2 million by age 50. You won’t be rich, but again, you’ll have more financial security than about 95% of Americans.

The best piece of financial advice I ever got was from Florida freelance writer David Kohn, who told me: “Live below your means.” Doing so further enhances your financial security.

With your wealth, avoid buying material possessions that are unnecessary – especially luxuries that depreciate in value over time. Use your money to buy income-producing assets, assets that appreciate in value, or services that free up your time for other activities.

Avoid debt of any kind to the extent you are able. I have zero consumer debt except the mortgages on investment properties. Cars I buy for cash. If you have to get a loan or lease to drive a particular model car, you can’t afford it.

If you lend money to friends or family, do it with the expectation that the money is really a gift rather than a loan,
and do not expect to ever get the money back. If you are repaid, even in part, consider it found money.

Every day you wake up and everyone in your family is in good health, and you have food to eat and a decent place to live, you are ahead of the game.

When writers, Internet marketers, and entrepreneurs brag to you about how much money they make, divide the figure they give by three. As my colleague Fred Gleeck is fond of pointing out, the only numbers you can trust are your own.

In your business, always under-promise and over-deliver. Give your customers not their money’s worth, but more than they have a right to expect. Err on the side of being too generous rather than being too rigid or strict.

Before criticizing a supplier or vendor, say something positive – what you like about the work — first. The more
insulted a vendor feels, the less motivated they become to serve you.

Do not allow yourself to be belittled, insulted, or demeaned verbally or in writing by others. When someone makes a snide or degrading comment, your reply should be: “What was your purpose in making that comment to me?” It will stop them in their tracks, and embarrass them so they never do it to you again.

Do not give people unsolicited advice.

To paraphrase Dan Kennedy, guard your time like the gold in Fort Knox. You can always make more money, but time lost or wasted is gone forever.

As long as a business or life decision does not involve risking the mortgage money, make it quickly. Successful people are able to make swift decisions and carry them out with speed.

The #1 difference between successful people and those less successful is that successful people act on their ideas. Ideas are a dime a dozen. Without action, ideas are worthless.

Do not think you must reinvent the wheel on every new product or business project. Most things have already been done before. All you need to do is add a twist or put your own spin on a product or service to create demand and make it profitable.

If you are successful, you can be arrogant and boastful, but why do it? Your bragging makes others who are less successful feel badly about themselves. What’s the point of doing that? Also, don’t refer to yourself as a genius or superstar in your marketing copy. If you were a genius, you wouldn’t have to say it – instead others would be saying it and you could quote them.

Focus on your work – on creating valuable products, giving great service, going the extra mile for your customers – rather than how much money you want to make.

Start investing right away, when you are young. Do this early enough, and compounding can make you rich. Wait until you’re 50 or 60, and you could find yourself in desperate straits. And diversify. Put 10% of your wealth in an investment that moves in opposition to the stock market, such as precious metals.

From Bob Bly.

Share and Enjoy:
  • Digg
  • Facebook
  • StumbleUpon
  • TwitThis

Why ideas are worthless

Awful idea = -1
Weak idea = 1
So-so idea = 5
Good idea = 10
Great idea = 15
Brilliant idea = 20

No execution = $1
Weak execution = $1000
So-so execution = $10,000
Good execution = $100,000
Great execution = $1,000,000
Brilliant execution = $10,000,000

To make a business, you need to multiply the two.

—Derek Sivers, president and programmer, CD Baby and HostBaby

Read more practical software and business advice at Getting Real

Share and Enjoy:
  • Digg
  • Facebook
  • StumbleUpon
  • TwitThis

Dollarize your time

A friend back in college once told me that he doesn’t measure his time in terms of minutes or hours but with pesos. I thought he was just drunk as we often were in college. Years later, when I started accepting freelance projects, I realized how important it is to put a dollar amount on every hour you work. The idea of dollarizing your time not only helps you in setting your hourly freelance rates. More importantly, it helps you make key decisions that affect your work, business, yourself, or your family.

You can focus on what you do best

When you dollarize your time, you can focus on your strengths and outsourcing your weakness will make sense. Working on SchoolPad (my first personal Ruby on Rails project) introduced me to the realities of working alone. I have to learn things like design and copywriting that I knew from the beginning would be hard for a coder like me. But, I had two things that will me help solve my problem – pride and money. I bought all the books I think would be useful and read them every day and night like I was preparing for a do-or-die college exam. In the end, I produced crap and had to beg a friend to salvage my work. After my SchoolPad experience, whenever I work on a freelance project, I make sure I identify the tasks that I can work on and find partners that can help me.

You will not be wasting time

I once complained to a friend that going to the movies is expensive. Then one time, he told me he got a discount (about $3 less) to the movie theater he was working for. He invited me to join him. The problem was it would be a 30-minute (at least) commute. Even if I brought my my wife and 2 kids, it still makes no sense to me. I would rather bring my family to the more expensive theater which is just 5 minutes away, and spend the hour playing in the park with my kids.

How to dollarize your time

The easy way is decide how much you want to earn every hour you work. If you set it at $40/hour, always remind yourself that your hour is worth $40. If you are unsure how many dollars to set, try this formula by Rob Walling (from the book Web Startup Success Guide):

Your $/hour = (current salary x 1.3) / 2000, rounded to the nearest $5 increment.
where 2,000 is approximate number of hours worked in a year

Share and Enjoy:
  • Digg
  • Facebook
  • StumbleUpon
  • TwitThis