Today, follow the depot example of the agile Web Development with Rails to automatically generate scaffold from a database table.
That day in the company to do this example, feel quite smooth, did not expect to change to the home today after the machine, there are many problems.
Here is a record of the problems and solutions.
1. After creating a good database and Products table, execute
Cmd>ruby Script/generate Scaffold Product
Result error
Exists app/controllers/
Error Beforeupdatingscaffoldingfromnewdbschema,trycreatingata
Leforyourmodel (Product)
A search on Google, there are about 2 kinds of solutions:
(1) in the Database.yml file, precede the password entry with a space (original address http://www.javaeye.com/post/264530)
(2) The data table name does not have a plural, by default, if the table is products, the command is ... scaffold product
This rule can be modified in the corresponding configuration file, specific Google, here is not much to say.
Both of these methods have been tried, but the problem remains.
(3) accidentally open database.yml file, found that there are a few tips:
#InstalltheMySQLdriver:
# Geminstallmysql
#OnMacOSX:
# geminstallmysql----Include=/usr/local/lib
#OnWindows:
# Geminstallmysql
# Choosethewin32build.
# Installmysqlandputits/bindirectoryonyourpath.
Then the implementation of the gem install MySQL, then the problem was solved. The strange thing is that I am in the same environment as the office, not performing the gem install MySQL, nor has the problem occurred. The only difference, hehe, is probably the slow speed of the home, the gem of the day Intall Rails when
It was interrupted several times, but the problem was solved.