I am having trouble getting the generate scaffold command to generate what I want. Here is my setup: Fedora Core 4 ruby -v => ruby 1.8.3 (2005-09-21) [i386-linux] rails -v => rails: version unknown gem -v => 0.8.11 I ran the command "ruby script/generate scaffold Product Admin", and expected it to create a model named ''product.rb'' and a controller named ''admin_controller.rb''. Instead of doing this, it creates the model ''product.rb'' and the controller ''product_controller.rb''. I thought it was supposed to create the model ''product.rb'' and controller ''admin_controller.rb''. Here is the usage example: Example: ./script/generate scaffold Account Bank debit credit This will generate an Account model and BankController with a full test suite and a basic user interface. Anyone know why this isn''t working? Thanks.
Chris- I''m not sure why the documentation says that but if you want to generate a product.rb model and an admin_controller.rb do this: $ script/generate scaffold admin Product The case seems to be important. As far back as I can remember when you generate scaffolding you tell it the lowercase controller name first then the upper case model name second. HTH- Cheers- -Ezra On Oct 11, 2005, at 10:18 AM, Chris Greene wrote:> I am having trouble getting the generate scaffold command to generate > what I want. Here is my setup: > > Fedora Core 4 > ruby -v => ruby 1.8.3 (2005-09-21) [i386-linux] > rails -v => rails: version unknown > gem -v => 0.8.11 > > I ran the command "ruby script/generate scaffold Product Admin", and > expected it to create a model named ''product.rb'' and a controller > named ''admin_controller.rb''. Instead of doing this, it creates the > model ''product.rb'' and the controller ''product_controller.rb''. I > thought it was supposed to create the model ''product.rb'' and > controller ''admin_controller.rb''. Here is the usage example: > > Example: > ./script/generate scaffold Account Bank debit credit > > This will generate an Account model and BankController with a > full test > suite and a basic user interface. > > Anyone know why this isn''t working? Thanks. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org
On 10/11/05, Ezra Zygmuntowicz <ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org> wrote:> Chris- > I''m not sure why the documentation says that but if you want to > generate a product.rb model and an admin_controller.rb do this: > > $ script/generate scaffold admin Product > > The case seems to be important. As far back as I can remember > when you generate scaffolding you tell it the lowercase controller > name first then the upper case model name second.Thanks for the reply. When do run "script/generate scaffold admin Product", I receive the error "error Before updating scaffolding from new DB schema, try creating a table for your model (Admin)" The documentation says it must be in the format of "script/generate scaffold [model] [controller]" product is the table in my database. I tried switching the model and controller around and using the proper case, but it still doesn''t generate admin_controller.rb. I got the Agile book when it came out and running this command worked fine then. I decided to upgrade my system to FC4 (fresh install) and now it doesn''t. I''ve had problems from the start. At first I wasn''t able to run "rails app_name". It is a known issue, and I had to download the beta version of gems by using "gem install rails --source http://gems.rubyonrails.com --include-dependencies". I also had to do some things to get rails to connect to mysql that I didn''t have to do before. Maybe it''s a problems with the beta rails.
On Oct 11, 2005, at 4:22 PM, Chris Greene wrote:> I got the Agile book when it came out and running this command worked > fine then. I decided to upgrade my system to FC4 (fresh install) and > now it doesn''t. I''ve had problems from the start. At first I wasn''t > able to run "rails app_name". It is a known issue, and I had to > download the beta version of gems by using "gem install rails --source > http://gems.rubyonrails.com --include-dependencies". I also had to do > some things to get rails to connect to mysql that I didn''t have to do > before. Maybe it''s a problems with the beta rails.For one, you''re using Ruby 1.8.3, which isn''t fully supported yet. As a newbie, I''d suggest backing down to 1.8.2 and moving Rails to .13.1 if you can. There have been some changes in scaffold generation, mostly to support scaffolding correctly when pluralization is turned off. I don''t see any changes in syntax (checking the diffs between my .13.1 install and my beta gem install). [1] The biggest difference between the .13.1 and the beta (.13.1.2417) gems re scaffolding is that in 2471, controller names are pluralized and are not skipped if a singular version of that model name exists. Another quirk I''ve noticed is that, at some point, many-to-many-join tables went from "categories_products" to "category_products" (only pluralizing the final word) -- which I''m fine with, it''s just a change that you''ll need to be aware of when reading older documentation. [1] That said, this is the first time I''ve read the code, so I could also be looking in the wrong place, or missing something that would be obvious had I been more familiar with the code. -- _Deirdre http://deirdre.net
> Another quirk I''ve noticed is that, at some point, many-to-many-join > tables went from "categories_products" to "category_products" (only > pluralizing the final word)Was that intentional? It seems a bit arbitrary, and conflicts with what''s in Agile Dev, which I thought was an absolute no-no with Rails releases through 1.0.
On Oct 11, 2005, at 7:51 PM, Andrew Otwell wrote:>> Another quirk I''ve noticed is that, at some point, many-to-many-join >> tables went from "categories_products" to "category_products" (only >> pluralizing the final word) >> > > Was that intentional? It seems a bit arbitrary, and conflicts with > what''s in Agile Dev, which I thought was an absolute no-no with > Rails releases through 1.0.I don''t know, I merely mentioned it for completeness. I think it makes more sense (and prevents certain issues).