I've been using Michael Hartl's RailsTutorial.org/book and it's been fantastic. I've thought long and hard about paying the $85 for his screen-capture-videos, but with being unemployed, I've decided to go the free route.
The tutorial is amazingly detailed and the explanations are fantastic. Michael does a great job of bringing the new-to-Rails programmer. ...
However, with that said, there are a few hiccups that I've found, so I thought I'd add them to my blog.
1) There is no such thing as an "activerecord-sqlite3-adapter". I had to post a question here before someone pointed me to the answer here. After the 2 hours of trying to find the answer, I did a small dance of joy at learning this.
... BUT THEN I discovered that this was all irrelevant because ...
2) Heroku does NOT support sqlite3!!!!! The tutorial directly says that it does, so maybe Heroku stopped supporting it lately. Regardless, since Rails is almost completely database independent, you'll need to install PostgreSQL if you want to deploy to Heroku. I found an awesome set of instructions for installing PostgreSQL here.
3) Annotate is currently broken. So, when you want add Annotate to your Gemfile, make this small change.
BEFORE FIX: gem 'annotate', '2.4.0'
AFTER FIX: gem 'annotate', '2.4.1.beta1'
You'll know it's broken because you'll receive a huge data dump error after running:
> bundle exec annotate --position before
4) In chapter #6, the tutorial introduces the 'rails console --sandbox' idea. This sandbox is great... except that it doesn't work with Postgres! I don't know why, but by nothing happens when we 'tail -f development.log'. Later, I tried the user.new and user.save options without the '--sandbox' flag, and it worked fine! Then, I just go into phppgadmin and remove the row from the database table.
5) In chapter 6.2, the tutorial asks you to run "bundle exec rake db:test:prepare". Using PostgreSQL, I found you MUST have a superuser account entered into your db config in order to run this. I tried a number of other options, and they all returned failure errors.
6) I found a strange error that turned out to just be a misunderstanding on my part. Apparently, in Ruby, there are some whitespaces that are REALLY bad! For instance, the first statement fails, but the second statement works! Go figure. Can you see the space between "User.new ("? Apparently, that's important!!!!
- user = User.new (:name => "", :email => "firstname.lastname@example.org") # FAILS!
- user = User.new(:name => "", :email => "email@example.com") # WORKS!
7) In chapter 7, we add a "salt" to the password. (I know, this "password" section is now obsolete due to Rails 3.1 having some "has_secure_password" thingy. But I'm going to try to follow the tutorial anyway. Should help me learn code, right?) Anyhow, with the "salt", I found that there was nothing in the tutorial to add "salt" into the database. Strange. So, I went back to the migration file (db/migration/___add_salt_to_users____.rb) and made it look like this:
class AddSaltToUsers < ActiveRecord::Migration
add_column :users, :salt, :string
Well, that should have been enough. Except that I must have done the "rake db:migration" thing wrong. So, I had to blow my databases away, and start again. In case I need to do it again, here's what I did:
1) In PhpPgAdmin, delete the "users" and "schema_migration" tables in both "_development" and "_test".
2) Enter these:
> bundle exec rake db:reset
> bundle exec rake db:migrate
> bundle exec rake db:test:prepare
I think all of these are overkill, as the db:migrate should have been enough. But it worked, so I'm happy. (Man, that was a frustrating bug to troubleshoot! Maybe, in the future, if I change the filename to reflect a later timestamp, and then make the changes, then the db:migrate will pick up the "add_column" and go with it!
Well, that's all my big hiccups so far. Maybe tomorrow will bring more!