Hi there, I''m brand new to Ruby, PHP is my usual trade but this stuff looks good, so here goes... I''ve tied following several of the tutorials, all with exactly the same result. The... <code> scaffold : <whatever /> </code> ...command doesn''t seem to work for me. I''m using Apache 2.0.52 on WinXP as my local web server and I tried restarting it several times. Currently I''m trying the ''cookbook'' tutorial. The error I get is... <code> ActiveRecord::StatementInvalid in Recipe#index Invalid argument: SELECT COUNT(*) FROM recipes <127.0.0.1/arc/cookbook/public/recipe#> Show framework trace C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connect ion_adapters/abstract_adapter.rb:462:in `log'' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connect ion_adapters/mysql_adapter.rb:121:in `execute'' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connect ion_adapters/mysql_adapter.rb:230:in `select'' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connect ion_adapters/mysql_adapter.rb:101:in `select_one'' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb :461:in `count_by_sql'' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb :454:in `count'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagina tion.rb:154:in `count_collection_for_pagination'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagina tion.rb:171:in `paginator_and_collection_for'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagina tion.rb:111:in `paginate'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/scaffo lding.rb:101:in `list'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/scaffo lding.rb:94:in `index'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.r b:756:in `send'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.r b:756:in `perform_action_without_filters'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/filter s.rb:295:in `perform_action_without_benchmark'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchm arking.rb:41:in `perform_action_without_rescue'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchm arking.rb:41:in `measure'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchm arking.rb:41:in `perform_action_without_rescue'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue .rb:80:in `perform_action'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.r b:356:in `send'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.r b:356:in `process'' C:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in `dispatch'' C:/apachefriends/xampp/htdocs/ARC/cookbook/public/dispatch.cgi:10 Request Parameters: None <127.0.0.1/arc/cookbook/public/recipe#> Show session dump --- flash: !ruby/hash:ActionController::Flash::FlashHash {} Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} </code> I''m sure you''ve all seen this a million times before, but I''m really stumped - I''m pretty sure I''ve followed the instructions to the letter, and I''ve even watched the videos! Help! Many thanks, Noel _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org lists.rubyonrails.org/mailman/listinfo/rails
What''s in the recipes database table? On 8/24/05, Noel <noel.dacosta-6XoTs0aBwg0qdlJmJB21zg@public.gmane.org> wrote:> > Hi there, > > I''m brand new to Ruby, PHP is my usual trade but this stuff looks good, so > here goes... > > I''ve tied following several of the tutorials, all with exactly the same > result. The... > > <code> > scaffold : <whatever /> > </code> > > ...command doesn''t seem to work for me. > > I''m using Apache 2.0.52 on WinXP as my local web server and I tried > restarting it several times. Currently I''m trying the ''cookbook'' tutorial. > The error I get is... > > > > <code> > ActiveRecord::StatementInvalid in Recipe#index Invalid argument: > SELECT COUNT(*) FROM recipes > > Show framework trace > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:462:in > `log'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:121:in > `execute'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:230:in > `select'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:101:in > `select_one'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:461:in > `count_by_sql'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:454:in > `count'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:154:in > `count_collection_for_pagination'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:171:in > `paginator_and_collection_for'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:111:in > `paginate'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/scaffolding.rb:101:in > `list'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/scaffolding.rb:94:in > `index'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in > `send'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in > `perform_action_without_filters'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/filters.rb:295:in > `perform_action_without_benchmark'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in > `perform_action_without_rescue'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in > `measure'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in > `perform_action_without_rescue'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in > `perform_action'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in > `send'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in > `process'' > > C:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in > `dispatch'' > > C:/apachefriends/xampp/htdocs/ARC/cookbook/public/dispatch.cgi:10 > > > > > > Request > > Parameters: None > > Show session dump > --- > flash: !ruby/hash:ActionController::Flash::FlashHash {} > > Response > Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} > > </code> > > > > I''m sure you''ve all seen this a million times before, but I''m really stumped > - I''m pretty sure I''ve followed the instructions to the letter, and I''ve > even watched the videos! > > Help! > > Many thanks, > Noel > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > lists.rubyonrails.org/mailman/listinfo/rails > > >
The colon has to directly precede the word - no space there. The colon is actually part of the next word - it''s a symbol.. much like $word indicates in PHP that "word" is a variable, :word in ruby indicates that "word" is a SYMBOL. I fell over on this one when I originally started with Rails, too because I hadn''t learnt enough Ruby. Julian. On 25/08/2005, at 4:28 AM, Noel wrote:> Hi there, > > I''m brand new to Ruby, PHP is my usual trade but this stuff looks > good, so here goes... > > I''ve tied following several of the tutorials, all with exactly the > same result. The... > > <code> > scaffold : <whatever /> > </code> > > ...command doesn''t seem to work for me. > > I''m using Apache 2.0.52 on WinXP as my local web server and I tried > restarting it several times. Currently I''m trying the ''cookbook'' > tutorial. The error I get is... > > > > <code> > ActiveRecord::StatementInvalid in Recipe#index > Invalid argument: SELECT COUNT(*) FROM recipes > Show framework trace > > > > Request > > Parameters: None > > Show session dump > > Response > > Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} > > </code> > > > > I''m sure you''ve all seen this a million times before, but I''m > really stumped - I''m pretty sure I''ve followed the instructions to > the letter, and I''ve even watched the videos! > > Help! > > Many thanks, > Noel > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org lists.rubyonrails.org/mailman/listinfo/rails
Hi there, Thanks to Joe and Julian for replying. This is my recipe_controller.rb: <code> class RecipeController < ApplicationController scaffold :recipe End </code> And the recipes database table looks like so: <code> -- Table structure for table `recipes` -- CREATE TABLE `recipes` ( `id` int(6) unsigned NOT NULL auto_increment, `title` varchar(255) NOT NULL default '''', `description` varchar(255) default NULL, `date` date default NULL, `instructions` text, `category_id` int(6) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table `recipes` -- INSERT INTO `recipes` VALUES (1, ''Hot Chips'', ''Only for the brave!'', ''2004-11-11'', '' Sprinkle hot-pepper sauce on corn chips.\r\n '', 1); INSERT INTO `recipes` VALUES (2, ''Ice Water'', ''Everyone''''s favorite.'', ''2004-11-11'', ''Put ice cubes in a glass of water.\r\n '', 2); </code> Trawling through the archives, I noticed a post on the same problem, which seemed to indicate that Rails only supports MySQL versions prior to 4.1. It is to do with the method of passing the password. There is supposed to be a fix; you create a special user, and convert the password to the old 3.x method using this shell command: <code> mysqladmin -u root -h localhost --password password "mypassword" </code> ...however, I tried that and it didn''t seem to have any effect. Any other ideas? Thanks, Noel -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Joe Van Dyk Sent: Wednesday, August 24, 2005 9:39 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] Scaffold broken What''s in the recipes database table? On 8/24/05, Noel <noel.dacosta-6XoTs0aBwg0qdlJmJB21zg@public.gmane.org> wrote:> > Hi there, > > I''m brand new to Ruby, PHP is my usual trade but this stuff looks > good, so here goes... > > I''ve tied following several of the tutorials, all with exactly the > same result. The... > > <code> > scaffold : <whatever /> > </code> > > ...command doesn''t seem to work for me. > > I''m using Apache 2.0.52 on WinXP as my local web server and I tried > restarting it several times. Currently I''m trying the ''cookbook'' tutorial. > The error I get is... > > > > <code> > ActiveRecord::StatementInvalid in Recipe#index Invalid argument: > SELECT COUNT(*) FROM recipes > > Show framework trace > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/c > onnection_adapters/abstract_adapter.rb:462:in > `log'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/c > onnection_adapters/mysql_adapter.rb:121:in > `execute'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/c > onnection_adapters/mysql_adapter.rb:230:in > `select'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/c > onnection_adapters/mysql_adapter.rb:101:in > `select_one'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/b > ase.rb:461:in > `count_by_sql'' > > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/b > ase.rb:454:in > `count'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > pagination.rb:154:in > `count_collection_for_pagination'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > pagination.rb:171:in > `paginator_and_collection_for'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > pagination.rb:111:in > `paginate'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > scaffolding.rb:101:in > `list'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > scaffolding.rb:94:in > `index'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > base.rb:756:in > `send'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > base.rb:756:in > `perform_action_without_filters'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > filters.rb:295:in > `perform_action_without_benchmark'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > benchmarking.rb:41:in > `perform_action_without_rescue'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > benchmarking.rb:41:in > `measure'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > benchmarking.rb:41:in > `perform_action_without_rescue'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > rescue.rb:80:in > `perform_action'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > base.rb:356:in > `send'' > > C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/ > base.rb:356:in > `process'' > > C:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in > `dispatch'' > > C:/apachefriends/xampp/htdocs/ARC/cookbook/public/dispatch.cgi:10 > > > > > > Request > > Parameters: None > > Show session dump > --- > flash: !ruby/hash:ActionController::Flash::FlashHash {} > > Response > Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} > > </code> > > > > I''m sure you''ve all seen this a million times before, but I''m really > stumped > - I''m pretty sure I''ve followed the instructions to the letter, and > I''ve even watched the videos! > > Help! > > Many thanks, > Noel > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org lists.rubyonrails.org/mailman/listinfo/rails ___________________________________________________________________ This message has been scanned by the Datanet MessageScreen Service. For more information please visit MessageScreen.co.uk
Noel wrote:> Trawling through the archives, I noticed a post on the same problem, which > seemed to indicate that Rails only supports MySQL versions prior to 4.1. It > is to do with the method of passing the password. There is supposed to be a > fix; you create a special user, and convert the password to the old 3.x > method using this shell command: > > <code> > mysqladmin -u root -h localhost --password password "mypassword" > </code>The standard way I use for getting MySQL 4.0 clients to work in MySQL 4.1 is: mysql> SET PASSWORD FOR ''username''@''hostname'' = OLD_PASSWORD(''mypassword''); This sets the password to the 4.0-style short password hash that old clients use. The explanation and reference is at dev.mysql.com/doc/mysql/en/password-hashing.html. Hope this helps, -- Alex