Hi, I am novice to rails and recently I started learning rails. Still um in the zero point…As I started making a project in rails following the book “Agile Web Developement with rails” I cant con not configure my application to work with mysql. It was a project named depot in the following book. If anyone have this please help me to understand how they connect the mysql database with ruby and execute successfully scaffold command to create a model Product and and a controller Admin.
If I also created database, configured the database.yml file followed by the book, and then I went for scaffold command but It cannot create all the files as like as in the book. And If start the script/server I found an error. but there should be a form as it is illustrated in the book.
If you show us your database.yml (not the password obviously) and the
command you enter and the errors you are seeing it may be easier for
us to help.
Colin
create.sql (saved in /db)
drop table if exists products;
create table products (
id int not null auto_increment,
title varchar(100) not null,
description text not null,
image_url varchar(200) not null,
price decimal(10, 2) not null,
primary key (id)
);
Database configuration file:
development:
adapter: mysql
database: depot_development
host: localhost
username:
password:
test:
adapter: mysql
database: depot_test
host: localhost
username:
password:
production:
adapter: mysql
database: depot_production
host: localhost
username:
password:
and then if i execute ruby script/server coomand then:
it shows:
Routing Error
No route matches "/admin" with {:method=>:get}
create.sql (saved in /db)
drop table if exists products;
create table products (
id int not null auto_increment,
title varchar(100) not null,
description text not null,
image_url varchar(200) not null,
price decimal(10, 2) not null,
primary key (id)
);
I don't understand what the above is for or what you are doing with it.
Database configuration file:
development:
adapter: mysql
database: depot_development
host: localhost
username:
password:
test:
adapter: mysql
database: depot_test
host: localhost
username:
password:
production:
adapter: mysql
database: depot_production
host: localhost
username:
password:
and then if i execute ruby script/server coomand then:
it shows:
Routing Error
No route matches "/admin" with {:method=>:get}
Are you saying that it shows that error immediately after starting the
server? i think it is more likely that it is when you enter a URL in
the browser. Is that correct. If so then it is not a db issue but a
routing issue. Have a look at the Rails Guide on routing
(http://guides.rubyonrails.org/). First though have a look at the
Getting Started guide. Work right through it and make sure you
understand all of it. Then work through all the other guides.
Colin
As you want to see the database.yml and errors which are showing I just mentioned above.
I am giving here again the database.yml files details:
development:
adapter: mysql
database: depot_development
host: localhost
username:
password:
test:
adapter: mysql
database: depot_test
host: localhost
username:
password:
production:
adapter: mysql
database: depot_production
host: localhost
username:
password:
Please Irfan do not top post, insert your reply at the appropriate
point in the previous message, this will help to follow the thread and
also help to make sure you answer all the questions. Thanks
In my previous mail I said:
Are you saying that it shows that error immediately after starting the
server? i think it is more likely that it is when you enter a URL in
the browser. Is that correct?
You have not answered that question
If so then it is not a db issue but a
routing issue. Have a look at the Rails Guide on routing
(http://guides.rubyonrails.org/). First though have a look at the
Getting Started guide. Work right through it and make sure you
understand all of it. Then work through all the other guides.
Have you done this?
As you want to see the database.yml and errors which are showing I just
mentioned above.
I am giving here again the database.yml files details:
development:
adapter: mysql
database: depot_development
host: localhost
username:
password:
test:
adapter: mysql
database: depot_test
host: localhost
username:
password:
production:
adapter: mysql
database: depot_production
host: localhost
username:
password:
That looks OK
Colin
Oh I am sorry for my previous email as I was in a hurry and checking the mail from another place and replying.
Now I am trying again! thanks
Dear Irfan Ahmed Rizvi!
I had many problems with databases in the beginning, especially with
mysql. I read the same book. If you go further, there will be
extremely good troubleshoots for you to help mysql configuration! I am
quite sure, that your answer will be there!
My way:
1. create and test your database! if u can add, delete tables and
columns manually, from console, than everything works well, you can
log in, have the good password, etc.
2. test ur database connection, try it, the same what you made
manually, but with rake commands or generated migrations - if u can,
or just try again the tutorial what u r reading!
3. if it doesn't work, try out another database. First it helped me a
lot not to change basic database, just let it be sqlite3. Later if u r
better, u can play with it easily!
4. maybe some dependent "modul" is missing, which makes Rails connect
to databases. if u have Linux check that u installed the full package!
Also check that the versions are okay: "rails --version" or "rails -
v" , also "gem list".
5. if nothing works, complete reinstall.
6. if u bought the book, i'm sure they will help you if u ask them!
Just don't give up! I know how hard is it, mostly if u r new to Rails,
and u stopped immediately because of database. Just keep going, it
will worth, u will see!
good luck,
for further help, feel free to write me in private!
gezope
Dear Gezope
Thanks for your inspiration, as I am new in this framework and of-course to new real life programing concept!. Please help me if you feel free and have time! I want to learn!
I have solved all the previous problems today! thanks to all of you:)