May 9, 2008
Generic-user-small Ray Schamp 5 posts

Topic: Agile Web Development with Rails, 3rd Edition / Depot app, adding price

The way I fixed it was to download the latest stable release of sqlite3 for 10.4 and build it from the source, which was easy, no snags:

untar the package
make a new directory in the folder that holds the source
cd into that, and run >../configure
Let it go, and then run > make

Note what > sqlite3 --version and >which sqlite3 returns

run > make install and see if > sqlite3 --version returns something different. If it’s the new version, you’re all set. If it’s the old one still, run > which sqlite3, and this should return the location of the new binary. I just replaced my old binary with the new one, and then it worked after that.

Sorry if these instructions are confusing, I’m sure there’s a better way to do this.

-Ray

 
May 8, 2008
Generic-user-small Ray Schamp 5 posts

Topic: Agile Web Development with Rails, 3rd Edition / What's <whatis linkend=... ?

I give up, what’s the deal is with things like this on page 107:


# <whatis linkend="wtf.attr.accessor">attr_reader</whatis...*TRUNC*

 
May 4, 2008
Generic-user-small Ray Schamp 5 posts

Topic: Agile Web Development with Rails, 3rd Edition / Depot app, adding price

Someone else will have to confirm this because I already built the latest version of sqlite3 and replaced my old binary with that one. It was pretty painless. Thanks for your help though.

I have found a few strange areas of the beta book as I’m reading it straight through—is it useful for people to post copy errors to this forum, or do you have proofreaders for that?

 
May 4, 2008
Generic-user-small Ray Schamp 5 posts

Topic: Agile Web Development with Rails, 3rd Edition / Depot app, adding price

Thanks for responding!

Apparently I am running 3.1.3, so since you have 3.4.2 I will look into upgrading. Here’s what I get:


ray-schamps-computer:~/Sites/ror/depot Ray$ sqlite3 test.db
SQLite version 3.1.3
Enter ".help" for instructions
sqlite> CREATE TABLE products ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) DEFAULT NULL, "description" varchar(255) DEFAULT NULL, "image_url" varchar(255) DEFAULT NULL, "created_at" datetime DEFAULT NULL, "updated_at" datetime DEFAULT NULL);
sqlite> ALTER TABLE products ADD "price" decimal(8,2) DEFAULT 0;
SQL error: near "ADD": syntax error
sqlite> ALTER TABLE products ADD [price] decimal(8,2) DEFAULT 0;
SQL error: near "ADD": syntax error
sqlite> .exit

After I updated sqlite, your tests work, but rails gives the same error. In my searches online I found a few other people with the similar problems if a program shipped expecting sqlite3 > 3.1, but didn’t warn OS 10.4 users to upgrade. It’s strange that the SQL syntax would have changed between versions…

I will see if rails sees the new version of sqlite after a restart.

Update: no, it was not a restart it needed, but a sudo gem install sqlite3-ruby. Works now!

Thanks a lot,
Ray

 
May 3, 2008
Generic-user-small Ray Schamp 5 posts

Topic: Agile Web Development with Rails, 3rd Edition / Depot app, adding price

Hi,
I’m working my way through the book, I’m at the step where we add a price column, and am getting an error I don’t know what to do with:


ray-schamps-computer:~/Sites/ror/depot Ray$ rake db:migrate        
(in /Users/Ray/Sites/ror/depot)
== 2 AddPriceToProduct: migrating =============================================
-- add_column(:products, :price, :decimal, {:precision=>8, :default=>0, :scale=>2})
rake aborted!
SQLite3::SQLException: near "ADD": syntax error: ALTER TABLE products ADD "price" decimal(8,2) DEFAULT 0

(See full trace by running task with --trace)

After it didn’t work initially, I copied and pasted from the download link:


class AddPriceToProduct < ActiveRecord::Migration
  def self.up
    add_column :products, :price, :decimal,
      :precision => 8, :scale => 2, :default => 0
  end

  def self.down
    remove_column :products, :price
  end
end

Can someone tell me what’s up?

Thanks,
Ray

PS I wish this forum comments box had a preview.

5 posts