<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'Depot app, adding price' | Pragmatic Forums</title>
    <link>http://forums.pragprog.com/forums/66/topics/408</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>Depot app, adding price posted by Sam Ruby @ Sat, 24 May 2008 01:51:58 -0000</title>
      <description>&lt;p&gt;Glad to see it all worked out.  I suspect that the real truth is that the with-sqlite-dir option was neither required nor supported and eventually you found a syntax which caused it to be ignored.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve updated this section for the next beta.  Hopefully in this way your experiences will help people save time.&lt;/p&gt;</description>
      <pubDate>Sat, 24 May 2008 01:51:58 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2887</guid>
      <author>Sam Ruby</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Rob Sandusky @ Fri, 23 May 2008 23:19:07 -0000</title>
      <description>&lt;p&gt;Hmm&amp;#8230;. doesn&amp;#8217;t like the&amp;#8212;with option:&lt;br /&gt;&lt;pre&gt;
sudo gem install sqlite3-ruby --with-sqlite-dir=/opt/local
Password:
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-sqlite-dir=/opt/local
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;For fun (and because I love getting error messages), I tried the following:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;sudo gem install sqlite3-ruby -- with-sqlite3-dir=/opt/local&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;added a space both before and after the &amp;#8221;&amp;#8212;&amp;#8221; ... I figured, why not? How bad could it be?&lt;/p&gt;


	&lt;p&gt;It seems to have worked. When I run the test script, I now get the correct version of SQLite: 3.5.9. So there&amp;#8217;s some progress.&lt;/p&gt;


	&lt;p&gt;When I run the rake db:migrate in the depot directory (from a fresh shell window), it too seems to complete. So looks like this might be the fix we&amp;#8217;ve been looking for (?)&lt;/p&gt;


	&lt;p&gt;Thanks for the assist.&lt;/p&gt;</description>
      <pubDate>Fri, 23 May 2008 23:19:07 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2885</guid>
      <author>Rob Sandusky</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Sam Ruby @ Fri, 23 May 2008 20:47:10 -0000</title>
      <description>&lt;p&gt;my bad.  should be sqlite3-ruby, thus:&lt;/p&gt;


&lt;pre&gt;
sudo gem install sqlite3-ruby --with-sqlite-dir=/opt/local
&lt;/pre&gt;

	&lt;p&gt;And, yes, I believe that the correct incantation is with a 3 in sqlite3-ruby and no 3 in sqlite-dir.&lt;/p&gt;</description>
      <pubDate>Fri, 23 May 2008 20:47:10 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2883</guid>
      <author>Sam Ruby</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Rob Sandusky @ Fri, 23 May 2008 04:00:10 -0000</title>
      <description>&lt;p&gt;The instructions for installing ports seem to have worked (though it took several hours for downloads and installation per the Darwin Ports instruction page&amp;#8212;might be worth letting your readers know in advance). It completed and reported a successful update of SQLite3 to v. 3.5.9 (and running sqlite3 at the Unix prompt verifies that v.3.5.9 is installed.)&lt;/p&gt;


	&lt;p&gt;I then ran:&lt;br /&gt;sudo gem install sqlite-ruby&amp;#8212;&amp;#8212;with-sqlite-dir=/opt/local&lt;/p&gt;


	&lt;p&gt;and encountered the following error:&lt;br /&gt;&lt;pre&gt;
ERROR:  Error installing sqlite-ruby:
        ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install sqlite-ruby -- --with-sqlite-dir=/opt/local
checking for main() in -lsqlite... no
checking for sqlite.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Regarding the test program, it too worked with the changes you noted, however it reports back that SQLite3 version 3.1.3 (obviously since the gem update failed as noted above)&lt;/p&gt;</description>
      <pubDate>Fri, 23 May 2008 04:00:10 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2878</guid>
      <author>Rob Sandusky</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Sam Ruby @ Thu, 22 May 2008 23:13:36 -0000</title>
      <description>&lt;p&gt;Now I am starting to understand the scope of the problem.  Prior versions of the book pointed users to two sets of instructions: one that allegedly was easier and was based on ports, and one that sounds scary and involved building from source.  The former set of instructions were on the web, and are long gone.  The latter set of instructions still sound scary (but their bark is truly worse than their bite).&lt;/p&gt;


	&lt;p&gt;The &lt;a href="http://darwinports.com/install/"&gt;instructions to install ports&lt;/a&gt; on Tiger, however, also look a bit scary.  But perhaps it is not too bad.  Step one is to run an installer.  Step two also is simply to run an installer.  Step three requires you to add two lines to a file.  Step four is yet another installer (or build from source).  Step five is simply one command.&lt;/p&gt;


	&lt;p&gt;Can you try these and see if they work for you?&lt;/p&gt;


	&lt;p&gt;If you get past that, you will be all set up to install all sorts of useful packages, not just the latest sqlite3.&lt;/p&gt;


	&lt;p&gt;Oh, and the reason you got an error on the test program is that it was designed to be run inside the depot directory.  Here&amp;#8217;s something that is a bit more standalone:&lt;br /&gt;&lt;pre&gt;
require 'rubygems'
require 'sqlite3'
tempname = "test.sqlite#{3+rand}" 
db = SQLite3::Database.new(tempname)
puts db.execute('select sqlite_version()')
db.close
File.unlink(tempname)
&lt;/pre&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 22 May 2008 23:13:36 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2876</guid>
      <author>Sam Ruby</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Rob Sandusky @ Thu, 22 May 2008 22:41:02 -0000</title>
      <description>&lt;p&gt;Under Tiger (10.4.11):&lt;/p&gt;


	&lt;p&gt;the &amp;#8220;port&amp;#8221; command is unrecognized at the &lt;span class="caps"&gt;UNIX&lt;/span&gt; prompt:&lt;br /&gt;sudo: port: command not found&lt;/p&gt;


	&lt;p&gt;Entering in the second bit of code pasted into a .rb file and running with ruby produces an error:&lt;/p&gt;


	&lt;p&gt;/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/errors.rb:94:in `check&amp;#8217;: could not open database: unable to open database file (SQLite3::CantOpenException)
        from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:112:in `initialize&amp;#8217;
        from checkSQLite.rb:5:in `new&amp;#8217;
        from checkSQLite.rb:5&lt;/p&gt;


	&lt;p&gt;Did I miss something? (Pardon my dunder-headedness, but am still a bit of a newbie.)&lt;/p&gt;</description>
      <pubDate>Thu, 22 May 2008 22:41:02 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2875</guid>
      <author>Rob Sandusky</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Sam Ruby @ Thu, 22 May 2008 22:10:47 -0000</title>
      <description>&lt;p&gt;I&amp;#8217;m running Leopard, so I don&amp;#8217;t have this problem, but from what I gather, the following &lt;strong&gt;should&lt;/strong&gt; work:&lt;/p&gt;


&lt;pre&gt;
sudo port upgrade sqlite3
gem install sqlite-ruby -- --with-sqlite-dir=/opt/local
&lt;/pre&gt;

	&lt;p&gt;You can verify which version of sqlite3 Ruby sees with the following code (can be put into a file and executed from the command line, or run in irb or in script/console):&lt;/p&gt;


&lt;pre&gt;
require 'rubygems'
require 'sqlite3'
db = SQLite3::Database.new('db/development.sqlite3')
puts db.execute('select sqlite_version()')
&lt;/pre&gt;

	&lt;p&gt;If this works for you, I&amp;#8217;ll update the book, and make this code available for easy download.&lt;/p&gt;</description>
      <pubDate>Thu, 22 May 2008 22:10:47 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2874</guid>
      <author>Sam Ruby</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Rob Sandusky @ Thu, 22 May 2008 21:09:16 -0000</title>
      <description>&lt;p&gt;I am running SQLite v. 3.1.3 as well (on &lt;span class="caps"&gt;OS X&lt;/span&gt; Tiger 10.4.11) and am having the same problems as defucius tai notes above.&lt;/p&gt;


	&lt;p&gt;Is there a simple fix for this yet that works for us newbies who aren&amp;#8217;t as familiar with the nuances of &lt;span class="caps"&gt;UNIX&lt;/span&gt;, such as building applications from source?&lt;/p&gt;


	&lt;p&gt;I seem to be spending more time updating, troubleshooting and searching for answers than learning Rails. (2nd edition seemed much simpler).&lt;/p&gt;</description>
      <pubDate>Thu, 22 May 2008 21:09:16 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2871</guid>
      <author>Rob Sandusky</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Ray Schamp @ Fri, 09 May 2008 04:16:14 -0000</title>
      <description>&lt;p&gt;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:&lt;/p&gt;


	&lt;p&gt;untar the package&lt;br /&gt;make a new directory in the folder that holds the source&lt;br /&gt;cd into that, and run &lt;code&gt;&amp;gt;../configure&lt;/code&gt;&lt;br /&gt;Let it go, and then run &lt;code&gt;&amp;gt; make&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Note what &lt;code&gt;&amp;gt; sqlite3 --version&lt;/code&gt; and &lt;code&gt;&amp;gt;which sqlite3&lt;/code&gt; returns&lt;/p&gt;


	&lt;p&gt;run &lt;code&gt;&amp;gt; make install&lt;/code&gt; and see if &lt;code&gt;&amp;gt; sqlite3 --version&lt;/code&gt; returns something different.  If it&amp;#8217;s the new version, you&amp;#8217;re all set.  If it&amp;#8217;s the old one still, run &lt;code&gt;&amp;gt; which sqlite3&lt;/code&gt;, 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.&lt;/p&gt;


	&lt;p&gt;Sorry if these instructions are confusing, I&amp;#8217;m sure there&amp;#8217;s a better way to do this.&lt;/p&gt;


	&lt;p&gt;-Ray&lt;/p&gt;</description>
      <pubDate>Fri, 09 May 2008 04:16:14 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2755</guid>
      <author>Ray Schamp</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by defucius tai @ Fri, 09 May 2008 03:17:19 -0000</title>
      <description>&lt;p&gt;hi, I am having the same problems with the &lt;span class="caps"&gt;ADD&lt;/span&gt; command with sqlite3 3.1.3. and the instruction above with the &lt;span class="caps"&gt;SWIG&lt;/span&gt; and to upgrade sqlite3 on macos 10.4 does not work for me.&lt;/p&gt;</description>
      <pubDate>Fri, 09 May 2008 03:17:19 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2754</guid>
      <author>defucius tai</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Dave Thomas @ Sun, 04 May 2008 21:32:42 -0000</title>
      <description>&lt;p&gt;Ray:&lt;/p&gt;


	&lt;p&gt;However, it&amp;#8217;s probably easier both for you and for us to log errors in the errata pages&#8212;just click the link at foot of each page and you&amp;#8217;ll be taken there.&lt;/p&gt;


	&lt;p&gt;Dave&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 21:32:42 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2732</guid>
      <author>Dave Thomas</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Sam Ruby @ Sun, 04 May 2008 15:57:38 -0000</title>
      <description>&lt;p&gt;There will be proofreaders, but any errors that are reported will be addressed, and undoubtedly will make the copyeditors jobs easier.&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 15:57:38 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2728</guid>
      <author>Sam Ruby</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Ray Schamp @ Sun, 04 May 2008 13:42:34 -0000</title>
      <description>&lt;p&gt;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.&lt;/p&gt;


	&lt;p&gt;I have found a few strange areas of the beta book as I&amp;#8217;m reading it straight through&amp;#8212;is it useful for people to post copy errors to this forum, or do you have proofreaders for that?&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 13:42:34 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2726</guid>
      <author>Ray Schamp</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Sam Ruby @ Sun, 04 May 2008 02:18:39 -0000</title>
      <description>&lt;p&gt;It looks like support for &lt;span class="caps"&gt;ALTER TABLE ADD COLUMN&lt;/span&gt; was added to &lt;a href="http://www.sqlite.org/changes.html"&gt;SQLite3&lt;/a&gt; in version 3.2.0.&lt;/p&gt;


	&lt;p&gt;I have found &lt;a href="http://wiki.rubyonrails.org/rails/pages/HowtoUseSQLite"&gt;this&lt;/a&gt; : On Mac &lt;span class="caps"&gt;OS X 10&lt;/span&gt;.4 Tiger, try uninstalling the gem (sudo gem uninstall sqlite3), then use DarwinPorts to install &lt;span class="caps"&gt;SWIG&lt;/span&gt; (sudo port install swig), then re-install the SQLite3 gem (sudo gem install sqlite3).&lt;/p&gt;


	&lt;p&gt;If you can verify that this works for you, I&amp;#8217;ll update the instructions in the book.&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 02:18:39 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2725</guid>
      <author>Sam Ruby</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Ray Schamp @ Sun, 04 May 2008 00:58:49 -0000</title>
      <description>&lt;p&gt;Thanks for responding!&lt;/p&gt;


	&lt;p&gt;Apparently I am running 3.1.3, so since you have 3.4.2 I will look into upgrading.  Here&amp;#8217;s what I get:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
ray-schamps-computer:~/Sites/ror/depot Ray$ sqlite3 test.db
SQLite version 3.1.3
Enter ".help" for instructions
sqlite&amp;gt; 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&amp;gt; ALTER TABLE products ADD "price" decimal(8,2) DEFAULT 0;
SQL error: near "ADD": syntax error
sqlite&amp;gt; ALTER TABLE products ADD [price] decimal(8,2) DEFAULT 0;
SQL error: near "ADD": syntax error
sqlite&amp;gt; .exit
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;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 &amp;gt; 3.1, but didn&#8217;t warn &lt;span class="caps"&gt;OS 10&lt;/span&gt;.4 users to upgrade. It&#8217;s strange that the &lt;span class="caps"&gt;SQL&lt;/span&gt; syntax would have changed between versions&#8230;&lt;/p&gt;


	&lt;p&gt;I will see if rails sees the new version of sqlite after a restart.&lt;/p&gt;


	&lt;p&gt;Update: no, it was not a restart it needed, but a &lt;code&gt;sudo gem install sqlite3-ruby&lt;/code&gt;.  Works now!&lt;/p&gt;


	&lt;p&gt;Thanks a lot,&lt;br /&gt;Ray&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 00:58:49 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2723</guid>
      <author>Ray Schamp</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Sam Ruby @ Sun, 04 May 2008 00:22:31 -0000</title>
      <description>&lt;p&gt;Try these commands directly against sqlite3.  Can you tell me if they work?  What version of sqlite are you running?&lt;/p&gt;


&lt;pre&gt;
$ sqlite3 test.db
SQLite version 3.4.2
Enter ".help" for instructions
sqlite&amp;gt; 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&amp;gt; ALTER TABLE products ADD "price" decimal(8,2) DEFAULT 0;
sqlite&amp;gt; .exit
&lt;/pre&gt;</description>
      <pubDate>Sun, 04 May 2008 00:22:31 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2722</guid>
      <author>Sam Ruby</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
    <item>
      <title>Depot app, adding price posted by Ray Schamp @ Sat, 03 May 2008 23:34:53 -0000</title>
      <description>&lt;p&gt;Hi,&lt;br /&gt;I&amp;#8217;m working my way through the book, I&amp;#8217;m at the step where we add a price column, and am getting an error I don&amp;#8217;t know what to do with:&lt;br /&gt;&lt;pre&gt;
&lt;code&gt;
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=&amp;gt;8, :default=&amp;gt;0, :scale=&amp;gt;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)
&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;After it didn&amp;#8217;t work initially, I copied and pasted from the download link:&lt;br /&gt;&lt;pre&gt;
&lt;code&gt;
class AddPriceToProduct &amp;lt; ActiveRecord::Migration
  def self.up
    add_column :products, :price, :decimal,
      :precision =&amp;gt; 8, :scale =&amp;gt; 2, :default =&amp;gt; 0
  end

  def self.down
    remove_column :products, :price
  end
end
&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;Can someone tell me what&amp;#8217;s up?&lt;/p&gt;


	&lt;p&gt;Thanks,&lt;br /&gt;Ray&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;PS I&lt;/span&gt; wish this forum comments box had a preview.&lt;/p&gt;</description>
      <pubDate>Sat, 03 May 2008 23:34:53 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:408:2720</guid>
      <author>Ray Schamp</author>
      <link>http://forums.pragprog.com/forums/66/topics/408</link>
    </item>
  </channel>
</rss>
