Topic: Facing troube with DEPOT tutorials


I am a very newbie to ROR and started learning from DEPOT application in the book Agile Web Development with Rails 3nd Edition Beta.

I have done everything in a right way as per my knowledge and checked 100's of times for possible bugs if I have made any but could not find where did I go wrong since I am not able to get the expected output on the browser.

OS - Windows XP
D/B - Mysql 5.0.83
ROR - Edge rails
IDE - Aptana

Let me explain what I have done so far...

I have created a database named -  depot_development
Under which I have created a table - products
Here is the info of the table

mysql> describe products;
| Field       | Type         | Null | Key | Default | Extra          |
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| created_at  | datetime     | YES  |     | NULL    |                |
| updated_at  | datetime     | YES  |     | NULL    |                |
| name        | varchar(255) | NO   |     | NULL    |                |
| description | varchar(255) | NO   |     | NULL    |                |
5 rows in set (0.03 sec)

Next in Aptana I created a new rails project

>rails depot

Then changed the database.yml settings to match with right username and password, then

>rake db:migrate - which got through successfully - so no problem in connecting to database

>script/generate scaffold product - which created some files without any problem

>rake db:migrate - which successfully completed

Then I start the server mongrel.

I go to the inbuilt browser in Aptana and hit :  , it shoots my application successfully.


Listing products

New product


When I hit on the "New product" link, again my application successfully launches the page


New product


BUT HERE IS THE PROBLEM.... I don't see any of the columns of my database table "products" like name, description like it shows in the pages of the book "Agile Web Development with Rails" with outputs of the application .... You can see above where I have described about the table "products".

Now if I simply hit the Create button, it simply add a new id and shows a message in green color which actually added only id to the table nothing else.

Here is the detailed info

mysql> select * from products;
| id | created_at          | updated_at          | name | description |
|  1 | 2009-07-06 23:27:48 | 2009-07-06 23:27:48 | NULL | NULL        |
1 row in set (0.00 sec)

I also tried with both possibilities having the Null value for "name" and "description"  as YES & NO (ie NULL and NOTNULL).

If we set YES for "name" and "description",
       the new id is added properly but no other fields showing is the problem here.
If we set NO for "name" and "description",
       I get the following error which is quite meaning full, cannot execute the query since name and description is defined as "should not be null"


ActiveRecord::StatementInvalid in ProductsController#create
Mysql::Error: Column 'name' cannot be null: INSERT INTO `products` (`name`, `updated_at`, `description`, `created_at`) VALUES(NULL, '2009-07-07 00:23:16', NULL, '2009-07-07 00:23:16')

So it is something like at the finishing point of the tutorial I am struggling with the rails ....

Tried in linux machine in the same way. But I had no chance of getting right output exactly the same problem I am facing here with APTANA in windows... Which is something should get clarified about.

I have detailed as much as I understand. Let me know if you need any more information.

Pieces of suggestions are appreciated. Awaiting !!!!

Last edited by csengineer (2009-07-06 20:39:49)

Re: Facing troube with DEPOT tutorials

Have you tried using Terminal?  You created your scaffold like so:

script/generate scaffold product name:string, decription:string...

I have had a similar problem before when using an IDE so I switched to the console and have found it to be much better.

Re: Facing troube with DEPOT tutorials

Hi Amaseuk,

  Thanks a bunch and yes I was wrong in the syntax while creating a scaffold. And also I am able to go fine with the Apatana IDE itself without any trouble if I use the right syntax as you have mentioned.

Again thanks a lot!!!