Sunday 6 April 2008

Reading rails 1.2 while learning rails 2.0

Learning rails 2.0 from a book about rails 1.2.6 keeps you awake, cause there are things that does not do exactly what it is described in the book.


depot>rails depot


Generates lots of code. Now to setup the database open the database.yml file in depot\config\ and correct it to match your database:


# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: mysql
database: depot_development
user: userNam
password: pass
test:
adapter: mysql
database: depot_test
user: userNam
password: pass

production:
adapter: mysql
database: depot_production
user: userNam
password: pass


then make use of the rake tool, to create the databases:


rake db:create:all


then to make the product scaffolding do the following:


depot>ruby script/generate scaffold Product title:string description:text image_url:string


And now its possible to start the server (ruby script/server) and create a product. following this url:


http://localhost:3000/products

No comments: