bbqbaker
2006-Feb-26 08:34 UTC
[Rails] please help: having problem with the scaffold commad, mysql.
i just recently purchase agile web dev book about ruby on rails and going through the whole project. well i am now stuck on creating the scaffold. I have been messing with settings for awhile now. here is the error: koloa@ubuntu:/var/www/depot$ ruby script/generate scaffold Product Admin exists app/controllers/ exists app/helpers/ exists app/views/admin exists test/functional/ dependency model exists app/models/ exists test/unit/ exists test/fixtures/ identical app/models/product.rb identical test/unit/product_test.rb identical test/fixtures/products.yml No such file or directory - /tmp/mysql.sock //////////////////////////////////////////////////////// now i have been searching the forums and google but getting even more confused. what is the difference between mysql.sock and mysqld.sock? is this file created when mysql starts? does mysql port number have to be the same that my RoR site is configured to? example my RoR site is localhost:3000, do I have to go into the mysql conf file and change the default 3203(or something) to 3000? thank you for the help!!!!!!!!!!!!! -- Posted via http://www.ruby-forum.com/.
On Sun, 2006-02-26 at 09:33 +0100, bbqbaker wrote:> i just recently purchase agile web dev book about ruby on rails and > going through the whole project. well i am now stuck on creating the > scaffold. I have been messing with settings for awhile now. here is the > error: > > koloa@ubuntu:/var/www/depot$ ruby script/generate scaffold Product Admin > exists app/controllers/ > exists app/helpers/ > exists app/views/admin > exists test/functional/ > dependency model > exists app/models/ > exists test/unit/ > exists test/fixtures/ > identical app/models/product.rb > identical test/unit/product_test.rb > identical test/fixtures/products.yml > No such file or directory - /tmp/mysql.sock > > //////////////////////////////////////////////////////// > > now i have been searching the forums and google but getting even more > confused. what is the difference between mysql.sock and mysqld.sock? is > this file created when mysql starts? > > does mysql port number have to be the same that my RoR site is > configured to? example my RoR site is localhost:3000, do I have to go > into the mysql conf file and change the default 3203(or something) to > 3000? thank you for the help!!!!!!!!!!!!!---- how to connect to mysql is totally dependent upon your setup. if on mysql windows...remove the socket and put port: 3306 and make sure that the port is not blocked by firewall (I presume TCP but unblock both TCP & UDP just in case) if mysql on Linux and it is localhost...chances are likely that the socket is /var/lib/mysql/mysql.sock if mysql is started on localhost...see if you can connect to it from command line. mysql DATABASE_NAME -h localhost -u USER_NAME -p and you can determine socket location (if available) by doing ps aux|grep mysql Craig
hi craig, thanks for the reply. ok, so mysql needs to have its own port number seprate from what my RoR site is located on? Right now, when I type mysql_config --socket, i do get "/var/lib/mysql/mysql.sock" but i am confused. what is the diffence between mysql.sock vs mysqld.sock? i start mysql by typing "sudo mysqld". Is this correct? I am using ubuntu. thanks Craig White wrote:> On Sun, 2006-02-26 at 09:33 +0100, bbqbaker wrote: >> dependency model >> now i have been searching the forums and google but getting even more >> confused. what is the difference between mysql.sock and mysqld.sock? is >> this file created when mysql starts? >> >> does mysql port number have to be the same that my RoR site is >> configured to? example my RoR site is localhost:3000, do I have to go >> into the mysql conf file and change the default 3203(or something) to >> 3000? thank you for the help!!!!!!!!!!!!! > ---- > how to connect to mysql is totally dependent upon your setup. > > if on mysql windows...remove the socket and put > > port: 3306 > > and make sure that the port is not blocked by firewall (I presume TCP > but unblock both TCP & UDP just in case) > > if mysql on Linux and it is localhost...chances are likely that the > socket is /var/lib/mysql/mysql.sock > > if mysql is started on localhost...see if you can connect to it from > command line. > > mysql DATABASE_NAME -h localhost -u USER_NAME -p > > and you can determine socket location (if available) by doing > > ps aux|grep mysql > > Craig-- Posted via http://www.ruby-forum.com/.
On Sun, 2006-02-26 at 17:33 +0100, bbqbaker wrote:> hi craig, thanks for the reply. > > ok, so mysql needs to have its own port number seprate from what my RoR > site is located on? > > Right now, when I type mysql_config --socket, i do get > "/var/lib/mysql/mysql.sock"---- this is what you should use then ----> > but i am confused. what is the diffence between mysql.sock vs > mysqld.sock?---- there isn''t a mysqld.sock ----> > i start mysql by typing "sudo mysqld". Is this correct? I am using > ubuntu.---- I doubt it...I''m not a ubuntu user and I would suspect that running... sudo /etc/init.d/mysqld start would be the ticket but if you haven''t already set up the initial db''s on mysql...you probably need to get some help from ubuntu group to get it going initially. once mysqld is running...then the reference to the socket /var/lib/mysql/mysql.sock is all you should need to talk to it (no ports necessary) You only use port numbers to connect to mysql server if... - mysql server is running on Windows or - mysql server is running on some machine other than localhost Craig> > > thanks > > > > Craig White wrote: > > On Sun, 2006-02-26 at 09:33 +0100, bbqbaker wrote: > >> dependency model > >> now i have been searching the forums and google but getting even more > >> confused. what is the difference between mysql.sock and mysqld.sock? is > >> this file created when mysql starts? > >> > >> does mysql port number have to be the same that my RoR site is > >> configured to? example my RoR site is localhost:3000, do I have to go > >> into the mysql conf file and change the default 3203(or something) to > >> 3000? thank you for the help!!!!!!!!!!!!! > > ---- > > how to connect to mysql is totally dependent upon your setup. > > > > if on mysql windows...remove the socket and put > > > > port: 3306 > > > > and make sure that the port is not blocked by firewall (I presume TCP > > but unblock both TCP & UDP just in case) > > > > if mysql on Linux and it is localhost...chances are likely that the > > socket is /var/lib/mysql/mysql.sock > > > > if mysql is started on localhost...see if you can connect to it from > > command line. > > > > mysql DATABASE_NAME -h localhost -u USER_NAME -p > > > > and you can determine socket location (if available) by doing > > > > ps aux|grep mysql > > > > Craig >
Hello, I have recently started learning RoR. I think it''s _fantastic_. I am absolutely blown away. OK, this is to prepare you to my idiotic question. Hopefully, I won''t be stoned. I am designing a simple application, where users can register, and: * Publish a photo album * Publish a simple blog with comments * Determine their list of friends and foes The application will obviously have a front end and a backend. The front end will give people a chance to search, and "find" members and blogs The back end will allow people to manage their profiles and add blog entries. Now: I like the idea of urls like this: domain.com/user/merc/blog Where: * "user" is the controller * "merc" is the user id * "blog" is the action (in this case, show the blog) The backend could be: domain.com/backend/merc/blog Where everything is as above, a part from the fact that "backend" is the controller. This does mean that each controller will have quite a few actions. I guess my question is: how do you decide what a "controller" is and does? How should I divide the application amongst several controllers? Well... I hope I didn''t embarrass myself too much. Thanks a lot and bye! Merc.
hi craig thanks again. so if i am connecting through localhost, it wouldnt matter if my port numbers are incorrect right? my computer is also running apache2, should i disable this? in the book that i have, it only mentions webrick. i will try what you suggested. thanks, Craig White wrote:> On Sun, 2006-02-26 at 17:33 +0100, bbqbaker wrote: >> hi craig, thanks for the reply. >> >> ok, so mysql needs to have its own port number seprate from what my RoR >> site is located on? >> >> Right now, when I type mysql_config --socket, i do get >> "/var/lib/mysql/mysql.sock" > ---- > this is what you should use then > ---- >> >> but i am confused. what is the diffence between mysql.sock vs >> mysqld.sock? > ---- > there isn''t a mysqld.sock > ---- >> >> i start mysql by typing "sudo mysqld". Is this correct? I am using >> ubuntu. > ---- > I doubt it...I''m not a ubuntu user and I would suspect that running... > > sudo /etc/init.d/mysqld start > > would be the ticket but if you haven''t already set up the initial db''s > on mysql...you probably need to get some help from ubuntu group to get > it going initially. > > once mysqld is running...then the reference to the > socket /var/lib/mysql/mysql.sock is all you should need to talk to it > (no ports necessary) You only use port numbers to connect to mysql > server if... > - mysql server is running on Windows > or > - mysql server is running on some machine other than localhost > > Craig-- Posted via http://www.ruby-forum.com/.
On Sun, 2006-02-26 at 18:19 +0100, koloa none wrote:> hi craig thanks again. so if i am connecting through localhost, it > wouldnt matter if my port numbers are incorrect right?---- localhost - no port numbers should be used in database.yml ----> > my computer is also running apache2, should i disable this?---- shouldn''t matter ----> > in the book that i have, it only mentions webrick. > > > i will try what you suggested. thanks, > > > Craig White wrote: > > On Sun, 2006-02-26 at 17:33 +0100, bbqbaker wrote: > >> hi craig, thanks for the reply. > >> > >> ok, so mysql needs to have its own port number seprate from what my RoR > >> site is located on? > >> > >> Right now, when I type mysql_config --socket, i do get > >> "/var/lib/mysql/mysql.sock" > > ---- > > this is what you should use then > > ---- > >> > >> but i am confused. what is the diffence between mysql.sock vs > >> mysqld.sock? > > ---- > > there isn''t a mysqld.sock > > ---- > >> > >> i start mysql by typing "sudo mysqld". Is this correct? I am using > >> ubuntu. > > ---- > > I doubt it...I''m not a ubuntu user and I would suspect that running... > > > > sudo /etc/init.d/mysqld start > > > > would be the ticket but if you haven''t already set up the initial db''s > > on mysql...you probably need to get some help from ubuntu group to get > > it going initially. > > > > once mysqld is running...then the reference to the > > socket /var/lib/mysql/mysql.sock is all you should need to talk to it > > (no ports necessary) You only use port numbers to connect to mysql > > server if... > > - mysql server is running on Windows > > or > > - mysql server is running on some machine other than localhost > > > > Craig > >
hi craig, seems like i am getting closer but now when i type "ruby script/generate scaffold Product Admin" in the ruby site home directory, i get "access denied for user ''root@localhost; (using password: NO) now i checked my database.yml and i put my root and pw there. is there anywhere else i need to set it? thanks, Craig White wrote:> On Sun, 2006-02-26 at 18:19 +0100, koloa none wrote: >> hi craig thanks again. so if i am connecting through localhost, it >> wouldnt matter if my port numbers are incorrect right? > ---- > localhost - no port numbers should be used in database.yml > ---- >> >> my computer is also running apache2, should i disable this? > ---- > shouldn''t matter > ------ Posted via http://www.ruby-forum.com/.
No - you need to be able to use mysql as root@localhost without a password as you have configured the database.yml That''s a mysql problem that you have to solve. Craig On Sun, 2006-02-26 at 19:03 +0100, koloa none wrote:> hi craig, > seems like i am getting closer but now when i type "ruby script/generate > scaffold Product Admin" in the ruby site home directory, i get "access > denied for user ''root@localhost; (using password: NO) > > now i checked my database.yml and i put my root and pw there. is there > anywhere else i need to set it? > > thanks, > > > Craig White wrote: > > On Sun, 2006-02-26 at 18:19 +0100, koloa none wrote: > >> hi craig thanks again. so if i am connecting through localhost, it > >> wouldnt matter if my port numbers are incorrect right? > > ---- > > localhost - no port numbers should be used in database.yml > > ---- > >> > >> my computer is also running apache2, should i disable this? > > ---- > > shouldn''t matter > > ---- > >
but when running the ruby command to generate the scaffold, how does ruby know to use root as the user vs another username that has all privileges to access the database? is it because when i created "rails depot", i used the sudo command and hence why its root? Craig White wrote:> No - you need to be able to use mysql as root@localhost without a > password as you have configured the database.yml > > That''s a mysql problem that you have to solve. > > Craig-- Posted via http://www.ruby-forum.com/.
rails uses the path_to_rails_app/config/database.yml data to determine username:, password:, host:, database_name:, [ port: | socket: ] MySQL mantains it''s own "users" db for usernames:, passwords:, hosts: Craig On Sun, 2006-02-26 at 21:15 +0100, koloa none wrote:> but when running the ruby command to generate the scaffold, how does > ruby know to use root as the user vs another username that has all > privileges to access the database? > > is it because when i created "rails depot", i used the sudo command and > hence why its root? > > > Craig White wrote: > > No - you need to be able to use mysql as root@localhost without a > > password as you have configured the database.yml > > > > That''s a mysql problem that you have to solve. > > > > Craig > >
hi craig, after almost all day i am getting closer. after much frustration, i reinstalled mysql. still that didnt solve the problem, but at least now i have a whole new error message. i was able to reset my root password since it was giving errors. well here is my new error. /// begin koloa@ubuntu:/var/www/depot$ ruby script/generate scaffold product Admin exists app/controllers/ exists app/helpers/ exists app/views/admin exists test/functional/ dependency model exists app/models/ exists test/unit/ exists test/fixtures/ identical app/models/product.rb identical test/unit/product_test.rb identical test/fixtures/products.yml error Before updating scaffolding from new DB schema, try creating a tab le for your model (Product) /// end now in the book it has the product table in the depot_development DB. now in Ruby rails must i signify that befor i type products? Craig White wrote:> rails uses the path_to_rails_app/config/database.yml data to determine > username:, password:, host:, database_name:, [ port: | socket: ] > > MySQL mantains it''s own "users" db for usernames:, passwords:, hosts: > > Craig-- Posted via http://www.ruby-forum.com/.
after reading the book some more, i noticed in the fine print that this problem may be due to a bad install of ruby mysql library. if this is so, what is the latest ruby mysql to get? thanks bbqbaker wrote:> > hi craig, after almost all day i am getting closer. after much > frustration, i reinstalled mysql. still that didnt solve the problem, > but at least now i have a whole new error message. i was able to reset > my root password since it was giving errors. well here is my new error. > > /// begin > > koloa@ubuntu:/var/www/depot$ ruby script/generate scaffold product Admin > exists app/controllers/ > exists app/helpers/ > exists app/views/admin > exists test/functional/ > dependency model > exists app/models/ > exists test/unit/ > exists test/fixtures/ > identical app/models/product.rb > identical test/unit/product_test.rb > identical test/fixtures/products.yml > error Before updating scaffolding from new DB schema, try > creating a tab le for your model (Product) > /// end > > now in the book it has the product table in the depot_development DB. > now in Ruby rails must i signify that befor i type products? > > Craig White wrote: >> rails uses the path_to_rails_app/config/database.yml data to determine >> username:, password:, host:, database_name:, [ port: | socket: ] >> >> MySQL mantains it''s own "users" db for usernames:, passwords:, hosts: >> >> Craig-- Posted via http://www.ruby-forum.com/.
in my synaptic package manager i have the following checked: libdbd-mysql-ruby, libdbd-mysql-ruby1.8, libdbd-mysql, and libdbd-mysql and this is what my site has: Ruby version 1.8.3 (i486-linux) RubyGems version 0.8.11 Rails version 1.0.0 Active Record version 1.13.2 Action Pack version 1.11.2 Action Web Service version 1.0.0 Action Mailer version 1.1.5 Active Support version 1.2.5 Application root /var/www/depot Environment development Database adapter mysql -- Posted via http://www.ruby-forum.com/.
On Mon, 2006-02-27 at 04:31 +0100, bbqbaker wrote:> after reading the book some more, i noticed in the fine print that this > problem may be due to a bad install of ruby mysql library. if this is > so, what is the latest ruby mysql to get? thanks >---- says it right at the very top of database.yml file that you have to edit to connect to your mysql db... # gem install mysql Craig
Here is my output: koloa@ubuntu:/var/www/depot/config$ sudo gem install mysql -- --include=/usr/local/lib Attempting local installation of ''mysql'' Local gem file not found: mysql*.gem Attempting remote installation of ''mysql'' Updating Gem source index for: http://gems.rubyforge.org Building native extensions. This could take a while... extconf.rb:1:in `require'': no such file to load -- mkmf (LoadError) from extconf.rb:1 ERROR: While executing gem ... (RuntimeError) ERROR: Failed to build gem native extension. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection. ruby extconf.rb install mysql -- --include=/usr/local/lib\n Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out I really appreciate you helping and being patient with such a noob! Craig White wrote:> On Mon, 2006-02-27 at 04:31 +0100, bbqbaker wrote: >> after reading the book some more, i noticed in the fine print that this >> problem may be due to a bad install of ruby mysql library. if this is >> so, what is the latest ruby mysql to get? thanks >> > ---- > says it right at the very top of database.yml file that you have to edit > to connect to your mysql db... > > # gem install mysql > > Craig-- Posted via http://www.ruby-forum.com/.
im not sure if things are getting worse or better: koloa@ubuntu:/var/www/depot$ gem install mysql -- --include=/usr/local/lib Attempting local installation of ''mysql'' Local gem file not found: mysql*.gem Attempting remote installation of ''mysql'' ERROR: While executing gem ... (Gem::FilePermissionError) You don''t have write permissions into the /usr/lib/ruby/gems/1.8 directory. koloa@ubuntu:/var/www/depot$ sudo gem install mysql -- --include=/usr/local/lib Attempting local installation of ''mysql'' Local gem file not found: mysql*.gem Attempting remote installation of ''mysql'' Building native extensions. This could take a while... *** 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. Provided configuration options: --with-opt-dir --with-opt-include=${opt-dir}/include --with-opt-lib=${opt-dir}/lib --with-make-prog=make --srcdir=. --curdir=/usr/lib/ruby/gems/1.8/gems/mysql-2.7 --ruby=/usr/bin/ruby1.8 --with-mysql-config --with-mysql-dir=/usr/local --with-mysql-include=${mysql-dir}/include --with-mysql-lib=${mysql-dir}/lib --with-mysqlclientlib=mysqlclient --with-mlib=m --with-mysqlclientlib=mysqlclient --with-zlib=z --with-mysqlclientlib=mysqlclient --with-socketlib=socket --with-mysqlclientlib=mysqlclient --with-nsllib=nsl --with-mysqlclientlib=mysqlclient ERROR: While executing gem ... (RuntimeError) ERROR: Failed to build gem native extension. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection. ruby extconf.rb install mysql -- --include=/usr/local/lib\nchecking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... yes checking for mysql_query() in -lmysqlclient... no -- Posted via http://www.ruby-forum.com/.
ok, i feel like i am close now. Successfully installed mysql-2.7. BUT i am still getting the "error Before updating scaffolding from new DB schema, try creating a table for your model (Product)" error... =( koloa@ubuntu:/var/www/depot$ sudo gem install mysql -- --include=/usr/local/lib Attempting local installation of ''mysql'' Local gem file not found: mysql*.gem Attempting remote installation of ''mysql'' Building native extensions. This could take a while... Makefile:111: warning: overriding commands for target `/usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib'' Makefile:109: warning: ignoring old commands for target `/usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib'' mysql.c: In function ?make_field_obj?: mysql.c:185: warning: unused variable ?hash? mysql.c: In function ?stmt_execute?: mysql.c:1316: warning: unused variable ?false? mysql.c: In function ?time_initialize?: mysql.c:1703: warning: control reaches end of non-void function mysql.c: In function ?stmt_execute?: mysql.c:1365: warning: ?t.time_type? is used uninitialized in this function mysql.c:1378: warning: ?t.time_type? is used uninitialized in this function Makefile:111: warning: overriding commands for target `/usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib'' Makefile:109: warning: ignoring old commands for target `/usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib'' ruby extconf.rb install mysql -- --include=/usr/local/lib checking for mysql_query() in -lmysqlclient... yes checking for mysql_ssl_set()... yes checking for mysql.h... no checking for mysql/mysql.h... yes creating Makefile make gcc -fPIC -Wall -g -O2 -fPIC -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_MYSQL_H -I/usr/local/include -c mysql.c gcc -shared -L"/usr/local/lib" -L"/usr/lib" -o mysql.so mysql.o -lruby1.8 -lmysqlclient -lpthread -ldl -lcrypt -lm -lc make install /usr/bin/install -c -m 0755 mysql.so /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib Successfully installed mysql-2.7 -- Posted via http://www.ruby-forum.com/.