+1 /Marcus>I suppose I can deal with get-text or something else of its ilk, butI''m still puzzled: Why doesn''t Rails have i18n support?
On 14-jul-2005, at 9:37, Marcus Andersson wrote:> +1 > > /Marcus > > >> I suppose I can deal with get-text or something else of its ilk, but >> > I''m still puzzled: Why doesn''t Rails have i18n support?+10. For now it is very hacky. The problem is that you have parts of rails which are not multibyte-safe, let alone i18n. Besides, i18n is _quite_a_challenge, I don''t think it can be a "boxed" solution. The amount in which it might be available can vary greatly: 1. Inflector? - proper i18zed inflection would require all stemmer/ linguistics libraries on the planet and then some. You can use pluralization in templates but this will anyway stay English for quite some time. 2. Dates/times - this is a must and shouldn''t be very difficult, and shouldn''t require locales 3. Symmetric object mirroring for languages - now that would be a real threat but I got no idea how this can be humanly handled. 4. Thorough tests for multibyte support (is it only me noticing that TextHelper#truncate inserts an illegal UTF sequence before the dotdotdot?), which will essentially make jcode and $KCODE=''u'' a requirement for running Rails (I think many will riot!) 5. Error messages - now that is kinda ridiculous. What I would love for Rails is that it might provide it''s own string filtering capabilities, so that a special object (of a soecial class?) will be contacted by the framework to format and output messages. Gettext does it but it makes function calls sprinkled all over the place - not neat. What it might be (just a sketch) class Railties::Translation # There was an error in the field bla def error_msg_on_field(field_name, message, relevant_data) end # There was an error in the field "foos" def fieldname(symbol) end #which charset we send? def charset_header_value end #how do we configure the database? def charset_adapter_command end end ...etc. Then it must be possible to implement such an object in your app - and all messages would be passed to it first. When using such a stub it will be left to the developer to determine i18n handling - and developers who know the languages they are working in will be much better off doing it for their language group than making 1 something which will work for everyone but partially. -- Julian "Julik" Tarkhanov
Julian ''Julik'' Tarkhanov said:>> I''m still puzzled: Why doesn''t Rails have i18n support? > > +10. > For now it is very hacky. The problem is that you have parts of rails > which are not multibyte-safe, let alone > i18n. Besides, i18n is _quite_a_challenge, I don''t think it can be a > "boxed" solution. The amount in which it might be available can vary > greatly:[snip] All the points Julian makes are good, but I think all you Railers are putting the cart before the horse. Really the problem is that Ruby itself needs better i18n support before Rails can get it. I''m sure there are various hacks you could make, but things will be much easier if Ruby itself solves a lot of these problems. As far as I know, i18n and l10n (localization) are some of the features on the list for Ruby 2.0, aka Rite. Ryan
On Jul 14, 2005, at 9:00 AM, Ryan Leavengood wrote:> Julian ''Julik'' Tarkhanov said: > >>> I''m still puzzled: Why doesn''t Rails have i18n support? >>> >> >> +10. >> For now it is very hacky. The problem is that you have parts of rails >> which are not multibyte-safe, let alone >> i18n. Besides, i18n is _quite_a_challenge, I don''t think it can be a >> "boxed" solution. The amount in which it might be available can vary >> greatly: >> > [snip] > > All the points Julian makes are good, but I think all you Railers are > putting the cart before the horse. Really the problem is that Ruby > itself > needs better i18n support before Rails can get it. I''m sure there are > various hacks you could make, but things will be much easier if Ruby > itself solves a lot of these problems. > > As far as I know, i18n and l10n (localization) are some of the > features on > the list for Ruby 2.0, aka Rite.+1. Good observation, Ryan. - Jamis
On 14-jul-2005, at 17:07, Jamis Buck wrote:> On Jul 14, 2005, at 9:00 AM, Ryan Leavengood wrote: >> >> As far as I know, i18n and l10n (localization) are some of the >> features on >> the list for Ruby 2.0, aka Rite. >> > > +1. Good observation, Ryan. >It was just me going too fast. What I thought about was actually l10n, not i18n :-) I can say that it is more than possible (necessary and done by everyone) to use Rails with Unicode (and Ruby support for it is actually in some ways better than PHPs - both are nonexistent but...). Of course it is a bit ahead of the cart, but Unicode exists and it has to be done _now_. We have the /u flag on regexen and KCODE - they both work to a certain extent. That''s why it seems strange to me that things such as truncate were not tested for multibyte-safeness. I, on the other hand, was talking about translations and localization - my fault, sorry. Actually the subject of this thread should be i10n ;-) -- Julian "Julik" Tarkhanov
On 7/14/05, Jamis Buck <jamis-uHoyYlH2B+GakBO8gow8eQ@public.gmane.org> wrote:> On Jul 14, 2005, at 9:00 AM, Ryan Leavengood wrote: > > > Julian ''Julik'' Tarkhanov said: > > > >>> I''m still puzzled: Why doesn''t Rails have i18n support? > >>> > >> > >> +10. > >> For now it is very hacky. The problem is that you have parts of rails > >> which are not multibyte-safe, let alone > >> i18n. Besides, i18n is _quite_a_challenge, I don''t think it can be a > >> "boxed" solution. The amount in which it might be available can vary > >> greatly: > >> > > [snip] > > > > All the points Julian makes are good, but I think all you Railers are > > putting the cart before the horse. Really the problem is that Ruby > > itself > > needs better i18n support before Rails can get it. I''m sure there are > > various hacks you could make, but things will be much easier if Ruby > > itself solves a lot of these problems. > > > > As far as I know, i18n and l10n (localization) are some of the > > features on > > the list for Ruby 2.0, aka Rite. > > +1. Good observation, Ryan.Isn''t Ruby 2.0 supposed to come by this next (fiscal) year? Anything we can do to speed up the release?
* Joe Van Dyk [2005-07-14 16:00]:> Isn''t Ruby 2.0 supposed to come by this next (fiscal) year? Anything > we can do to speed up the release?Sacrifice camels. -- ________________________________ toddgrimason*todd[ at ]slack.net
I agree, l10n is the #1 hole I see in Ruby (and by extension, Rails). Most of the complaints, or debate, or what have you against Rails, say from the Java community, or whatever, tends to be around performance and scalability, which as we all know from recent threads is a non-issue (or rather an issue that is not due to it being Ruby or Rails). When folks ask me about how Rails stacks up to say using Java for web apps, this is really the only negative point (and it''s a big one IMHO) I have. I will say that part depends on your perspective and what kind of apps you develop. Tons of web apps are only available in English, and it''s probably a non-issue for many folks. But, if you develop software for a commercial organization that sells software throughout the world, it is a critical feature. It is the only thing that has me hesitate to use it in my day-job projects (we currently use Java). It would be great to see Ruby gain both the localization and internationalization features that Java has, and then for Rails to have features that take advantage of that, similar to how something like JSP 2.0/JSTL, and/or Spring, Struts, etc. provide mechanisms to nicely integrate at least localization features. I would like to help, or offer a solution in this area, instead of just complaining, but the area is also not my forte. I thought there was some project (can''t seem to find link now) called "MLS" or "MSL" or something along those lines that was making efforts here. Also, Ri18n, which may be of interest: http://ri18n.berlios.de/ Also, I haven''t looked at it closely, but the Nitro Ruby framework has something called the LocalizationShader that appears to allow you to do localized string substitution. On 7/14/05 11:26 AM, "Julian ''Julik'' Tarkhanov" <listbox-RY+snkucC20@public.gmane.org> wrote:> > On 14-jul-2005, at 17:07, Jamis Buck wrote: > >> On Jul 14, 2005, at 9:00 AM, Ryan Leavengood wrote: >>> >>> As far as I know, i18n and l10n (localization) are some of the >>> features on >>> the list for Ruby 2.0, aka Rite. >>> >> >> +1. Good observation, Ryan. >> > > It was just me going too fast. What I thought about was actually > l10n, not i18n :-) > I can say that it is more than possible (necessary and done by > everyone) to use Rails with Unicode > (and Ruby support for it is actually in some ways better than PHPs - > both are nonexistent but...). > > Of course it is a bit ahead of the cart, but Unicode exists and it > has to be done _now_. We have the /u flag on regexen and KCODE - they > both work to a certain extent. That''s why it seems strange to me that > things such as truncate were not tested for multibyte-safeness. > > I, on the other hand, was talking about translations and localization > - my fault, sorry. Actually the subject of this thread should be > i10n ;-) >
Hello, I asked the community earlier if I should be using the script/generate code creation stuff - the answer was yes. So I''m trying to use it to create a scaffold but it doesn''t seem to work. Below is a transcript of creating this application from scratch, finally leading to the error "Before updating scaffolding from new DB schema, try creating a table for your model (Person)". Is this happening because I have left the golden path by adding def self.table_name() "contacts.people" end to my model? Does generate only work for the golden path? After going to extensive effort to create a database that is golden path compliant I seem to have ended up on the brown path. Any help much appreciated in advance. here''s the transcript of what I did - cheers andrew [root@xsecore html]# rm -rf temp [root@xsecore html]# rails temp create create app/apis create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create components create db create doc create lib create log create public/images create public/javascripts create public/stylesheets create script create test/fixtures create test/functional create test/mocks/development create test/mocks/test create test/unit create vendor create Rakefile create README create CHANGELOG create app/controllers/application.rb create app/helpers/application_helper.rb create test/test_helper.rb create config/database.yml create config/routes.rb create public/.htaccess create config/environment.rb create config/environments/production.rb create config/environments/development.rb create config/environments/test.rb create script/console create script/destroy create script/generate create script/server create script/runner create script/benchmarker create script/profiler create script/breakpointer create public/dispatch.rb create public/dispatch.cgi create public/dispatch.fcgi create public/404.html create public/500.html create public/index.html create public/favicon.ico create public/javascripts/prototype.js create public/javascripts/effects.js create public/javascripts/dragdrop.js create public/javascripts/controls.js create doc/README_FOR_APP create log/server.log create log/production.log create log/development.log create log/test.log [root@xsecore html]# cd temp/config [root@xsecore config]# cp /var/www/html/frr/config/database.yml . cp: overwrite `./database.yml''? y [root@xsecore config]# cd .. [root@xsecore temp]# script/generate model Person exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/person.rb create test/unit/person_test.rb create test/fixtures/people.yml [root@xsecore temp]# cd app [root@xsecore app]# cd models [root@xsecore models]# more person.rb class Person < ActiveRecord::Base end [root@xsecore models]# vi person.rb [root@xsecore models]# cat person.rb class Person < ActiveRecord::Base def self.table_name() "contacts.people" end end [root@xsecore models]# cd .. [root@xsecore app]# cd .. [root@xsecore temp]# script/generate controller Person exists app/controllers/ exists app/helpers/ create app/views/person exists test/functional/ create app/controllers/person_controller.rb create test/functional/person_controller_test.rb create app/helpers/person_helper.rb [root@xsecore temp]# [root@xsecore temp]# ls app CHANGELOG components config db doc lib log public Rakefile README script test vendor [root@xsecore temp]# script/generate scaffold Person dependency model exists app/models/ exists test/unit/ exists test/fixtures/ skip app/models/person.rb skip test/unit/person_test.rb skip test/fixtures/people.yml exists app/controllers/ exists app/helpers/ create app/views/people exists test/functional/ create app/controllers/people_controller.rb create test/functional/people_controller_test.rb create app/helpers/people_helper.rb create app/views/layouts/people.rhtml create public/stylesheets/scaffold.css create app/views/people/list.rhtml create app/views/people/show.rhtml create app/views/people/new.rhtml create app/views/people/edit.rhtml error Before updating scaffolding from new DB schema, try creating a table for your model (Person) [root@xsecore temp]#
What is "golden path"? - Neeraj On 7/14/05, Andrew Stuart <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> wrote:> Hello, > > I asked the community earlier if I should be using the script/generate code > creation stuff - the answer was yes. So I''m trying to use it to create a > scaffold but it doesn''t seem to work. Below is a transcript of creating > this application from scratch, finally leading to the error "Before updating > scaffolding from new DB schema, try creating a table for your model > (Person)". > > Is this happening because I have left the golden path by adding def > self.table_name() "contacts.people" end to my model? > > Does generate only work for the golden path? After going to extensive > effort to create a database that is golden path compliant I seem to have > ended up on the brown path. > > Any help much appreciated in advance. here''s the transcript of what I did - > cheers andrew > > [root@xsecore html]# rm -rf temp > [root@xsecore html]# rails temp > create > create app/apis > create app/controllers > create app/helpers > create app/models > create app/views/layouts > create config/environments > create components > create db > create doc > create lib > create log > create public/images > create public/javascripts > create public/stylesheets > create script > create test/fixtures > create test/functional > create test/mocks/development > create test/mocks/test > create test/unit > create vendor > create Rakefile > create README > create CHANGELOG > create app/controllers/application.rb > create app/helpers/application_helper.rb > create test/test_helper.rb > create config/database.yml > create config/routes.rb > create public/.htaccess > create config/environment.rb > create config/environments/production.rb > create config/environments/development.rb > create config/environments/test.rb > create script/console > create script/destroy > create script/generate > create script/server > create script/runner > create script/benchmarker > create script/profiler > create script/breakpointer > create public/dispatch.rb > create public/dispatch.cgi > create public/dispatch.fcgi > create public/404.html > create public/500.html > create public/index.html > create public/favicon.ico > create public/javascripts/prototype.js > create public/javascripts/effects.js > create public/javascripts/dragdrop.js > create public/javascripts/controls.js > create doc/README_FOR_APP > create log/server.log > create log/production.log > create log/development.log > create log/test.log > [root@xsecore html]# cd temp/config > [root@xsecore config]# cp /var/www/html/frr/config/database.yml . > cp: overwrite `./database.yml''? y > [root@xsecore config]# cd .. > [root@xsecore temp]# script/generate model Person > exists app/models/ > exists test/unit/ > exists test/fixtures/ > create app/models/person.rb > create test/unit/person_test.rb > create test/fixtures/people.yml > [root@xsecore temp]# cd app > [root@xsecore app]# cd models > [root@xsecore models]# more person.rb > class Person < ActiveRecord::Base > end > [root@xsecore models]# vi person.rb > [root@xsecore models]# cat person.rb > class Person < ActiveRecord::Base > def self.table_name() > "contacts.people" > end > > end > [root@xsecore models]# cd .. > [root@xsecore app]# cd .. > [root@xsecore temp]# script/generate controller Person > exists app/controllers/ > exists app/helpers/ > create app/views/person > exists test/functional/ > create app/controllers/person_controller.rb > create test/functional/person_controller_test.rb > create app/helpers/person_helper.rb > [root@xsecore temp]# > [root@xsecore temp]# ls > app CHANGELOG components config db doc lib log public Rakefile > README script test vendor > [root@xsecore temp]# script/generate scaffold Person > dependency model > exists app/models/ > exists test/unit/ > exists test/fixtures/ > skip app/models/person.rb > skip test/unit/person_test.rb > skip test/fixtures/people.yml > exists app/controllers/ > exists app/helpers/ > create app/views/people > exists test/functional/ > create app/controllers/people_controller.rb > create test/functional/people_controller_test.rb > create app/helpers/people_helper.rb > create app/views/layouts/people.rhtml > create public/stylesheets/scaffold.css > create app/views/people/list.rhtml > create app/views/people/show.rhtml > create app/views/people/new.rhtml > create app/views/people/edit.rhtml > error Before updating scaffolding from new DB schema, try creating a > table for your model (Person) > [root@xsecore temp]# > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 7/14/05, Andrew Stuart <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> wrote:> Hello, > > I asked the community earlier if I should be using the script/generate code > creation stuff - the answer was yes. So I''m trying to use it to create a > scaffold but it doesn''t seem to work. Below is a transcript of creating > this application from scratch, finally leading to the error "Before updating > scaffolding from new DB schema, try creating a table for your model > (Person)". > > Is this happening because I have left the golden path by adding def > self.table_name() "contacts.people" end to my model? > > Does generate only work for the golden path? After going to extensive > effort to create a database that is golden path compliant I seem to have > ended up on the brown path. > > Any help much appreciated in advance. here''s the transcript of what I did - > cheers andrew > > [root@xsecore html]# rm -rf temp > [root@xsecore html]# rails temp > create > create app/apis > create app/controllers > create app/helpers > create app/models > create app/views/layouts > create config/environments > create components > create db > create doc > create lib > create log > create public/images > create public/javascripts > create public/stylesheets > create script > create test/fixtures > create test/functional > create test/mocks/development > create test/mocks/test > create test/unit > create vendor > create Rakefile > create README > create CHANGELOG > create app/controllers/application.rb > create app/helpers/application_helper.rb > create test/test_helper.rb > create config/database.yml > create config/routes.rb > create public/.htaccess > create config/environment.rb > create config/environments/production.rb > create config/environments/development.rb > create config/environments/test.rb > create script/console > create script/destroy > create script/generate > create script/server > create script/runner > create script/benchmarker > create script/profiler > create script/breakpointer > create public/dispatch.rb > create public/dispatch.cgi > create public/dispatch.fcgi > create public/404.html > create public/500.html > create public/index.html > create public/favicon.ico > create public/javascripts/prototype.js > create public/javascripts/effects.js > create public/javascripts/dragdrop.js > create public/javascripts/controls.js > create doc/README_FOR_APP > create log/server.log > create log/production.log > create log/development.log > create log/test.log > [root@xsecore html]# cd temp/config > [root@xsecore config]# cp /var/www/html/frr/config/database.yml . > cp: overwrite `./database.yml''? y > [root@xsecore config]# cd .. > [root@xsecore temp]# script/generate model Person > exists app/models/ > exists test/unit/ > exists test/fixtures/ > create app/models/person.rb > create test/unit/person_test.rb > create test/fixtures/people.yml > [root@xsecore temp]# cd app > [root@xsecore app]# cd models > [root@xsecore models]# more person.rb > class Person < ActiveRecord::Base > end > [root@xsecore models]# vi person.rb > [root@xsecore models]# cat person.rb > class Person < ActiveRecord::Base > def self.table_name() > "contacts.people" > end > > end > [root@xsecore models]# cd .. > [root@xsecore app]# cd .. > [root@xsecore temp]# script/generate controller Person > exists app/controllers/ > exists app/helpers/ > create app/views/person > exists test/functional/ > create app/controllers/person_controller.rb > create test/functional/person_controller_test.rb > create app/helpers/person_helper.rb > [root@xsecore temp]# > [root@xsecore temp]# ls > app CHANGELOG components config db doc lib log public Rakefile > README script test vendor > [root@xsecore temp]# script/generate scaffold Person > dependency model > exists app/models/ > exists test/unit/ > exists test/fixtures/ > skip app/models/person.rb > skip test/unit/person_test.rb > skip test/fixtures/people.yml > exists app/controllers/ > exists app/helpers/ > create app/views/people > exists test/functional/ > create app/controllers/people_controller.rb > create test/functional/people_controller_test.rb > create app/helpers/people_helper.rb > create app/views/layouts/people.rhtml > create public/stylesheets/scaffold.css > create app/views/people/list.rhtml > create app/views/people/show.rhtml > create app/views/people/new.rhtml > create app/views/people/edit.rhtml > error Before updating scaffolding from new DB schema, try creating a > table for your model (Person) > [root@xsecore temp]#Do you have the database all set up? Can you run ''rake'' to run all the unit tests ok? Scaffolding needs access to the database, obviously.
Hi Joe - thanks for helping. If I add scaffold :person to my controller as follows, then everything seems to work okay. class PersonController < ApplicationController model :person scaffold :person end I need to modify the code though so it''s not really practical to work with the default scaffold, I''d rather generate the code and modify that to my needs. Andrew ----- Original Message ----- From: "Joe Van Dyk" <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: "Andrew Stuart" <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org>; <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Friday, July 15, 2005 1:32 PM Subject: Re: [Rails] script/generate scaffold problem On 7/14/05, Andrew Stuart <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> wrote:> Hello, > > I asked the community earlier if I should be using the script/generatecode> creation stuff - the answer was yes. So I''m trying to use it to create a > scaffold but it doesn''t seem to work. Below is a transcript of creating > this application from scratch, finally leading to the error "Beforeupdating> scaffolding from new DB schema, try creating a table for your model > (Person)". > > Is this happening because I have left the golden path by adding def > self.table_name() "contacts.people" end to my model? > > Does generate only work for the golden path? After going to extensive > effort to create a database that is golden path compliant I seem to have > ended up on the brown path. > > Any help much appreciated in advance. here''s the transcript of what Idid -> cheers andrew > > [root@xsecore html]# rm -rf temp > [root@xsecore html]# rails temp > create > create app/apis > create app/controllers > create app/helpers > create app/models > create app/views/layouts > create config/environments > create components > create db > create doc > create lib > create log > create public/images > create public/javascripts > create public/stylesheets > create script > create test/fixtures > create test/functional > create test/mocks/development > create test/mocks/test > create test/unit > create vendor > create Rakefile > create README > create CHANGELOG > create app/controllers/application.rb > create app/helpers/application_helper.rb > create test/test_helper.rb > create config/database.yml > create config/routes.rb > create public/.htaccess > create config/environment.rb > create config/environments/production.rb > create config/environments/development.rb > create config/environments/test.rb > create script/console > create script/destroy > create script/generate > create script/server > create script/runner > create script/benchmarker > create script/profiler > create script/breakpointer > create public/dispatch.rb > create public/dispatch.cgi > create public/dispatch.fcgi > create public/404.html > create public/500.html > create public/index.html > create public/favicon.ico > create public/javascripts/prototype.js > create public/javascripts/effects.js > create public/javascripts/dragdrop.js > create public/javascripts/controls.js > create doc/README_FOR_APP > create log/server.log > create log/production.log > create log/development.log > create log/test.log > [root@xsecore html]# cd temp/config > [root@xsecore config]# cp /var/www/html/frr/config/database.yml . > cp: overwrite `./database.yml''? y > [root@xsecore config]# cd .. > [root@xsecore temp]# script/generate model Person > exists app/models/ > exists test/unit/ > exists test/fixtures/ > create app/models/person.rb > create test/unit/person_test.rb > create test/fixtures/people.yml > [root@xsecore temp]# cd app > [root@xsecore app]# cd models > [root@xsecore models]# more person.rb > class Person < ActiveRecord::Base > end > [root@xsecore models]# vi person.rb > [root@xsecore models]# cat person.rb > class Person < ActiveRecord::Base > def self.table_name() > "contacts.people" > end > > end > [root@xsecore models]# cd .. > [root@xsecore app]# cd .. > [root@xsecore temp]# script/generate controller Person > exists app/controllers/ > exists app/helpers/ > create app/views/person > exists test/functional/ > create app/controllers/person_controller.rb > create test/functional/person_controller_test.rb > create app/helpers/person_helper.rb > [root@xsecore temp]# > [root@xsecore temp]# ls > app CHANGELOG components config db doc lib log public Rakefile > README script test vendor > [root@xsecore temp]# script/generate scaffold Person > dependency model > exists app/models/ > exists test/unit/ > exists test/fixtures/ > skip app/models/person.rb > skip test/unit/person_test.rb > skip test/fixtures/people.yml > exists app/controllers/ > exists app/helpers/ > create app/views/people > exists test/functional/ > create app/controllers/people_controller.rb > create test/functional/people_controller_test.rb > create app/helpers/people_helper.rb > create app/views/layouts/people.rhtml > create public/stylesheets/scaffold.css > create app/views/people/list.rhtml > create app/views/people/show.rhtml > create app/views/people/new.rhtml > create app/views/people/edit.rhtml > error Before updating scaffolding from new DB schema, try creatinga> table for your model (Person) > [root@xsecore temp]#Do you have the database all set up? Can you run ''rake'' to run all the unit tests ok? Scaffolding needs access to the database, obviously.
On 7/14/05, Andrew Stuart <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> wrote:> Hi Joe - thanks for helping. > > If I add scaffold :person to my controller as follows, then everything seems > to work okay. > > class PersonController < ApplicationController > model :person > scaffold :person > end > > I need to modify the code though so it''s not really practical to work with > the default scaffold, I''d rather generate the code and modify that to my > needs.And running ''rake'' works ok? If it does, sounds like the scaffold generator doesn''t know the table''s actual name (i.e. bug).> ----- Original Message ----- > From: "Joe Van Dyk" <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > To: "Andrew Stuart" <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org>; > <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Sent: Friday, July 15, 2005 1:32 PM > Subject: Re: [Rails] script/generate scaffold problem > > > On 7/14/05, Andrew Stuart <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> wrote: > > Hello, > > > > I asked the community earlier if I should be using the script/generate > code > > creation stuff - the answer was yes. So I''m trying to use it to create a > > scaffold but it doesn''t seem to work. Below is a transcript of creating > > this application from scratch, finally leading to the error "Before > updating > > scaffolding from new DB schema, try creating a table for your model > > (Person)". > > > > Is this happening because I have left the golden path by adding def > > self.table_name() "contacts.people" end to my model? > > > > Does generate only work for the golden path? After going to extensive > > effort to create a database that is golden path compliant I seem to have > > ended up on the brown path. > > > > Any help much appreciated in advance. here''s the transcript of what I > did - > > cheers andrew > > > > [root@xsecore html]# rm -rf temp > > [root@xsecore html]# rails temp > > create > > create app/apis > > create app/controllers > > create app/helpers > > create app/models > > create app/views/layouts > > create config/environments > > create components > > create db > > create doc > > create lib > > create log > > create public/images > > create public/javascripts > > create public/stylesheets > > create script > > create test/fixtures > > create test/functional > > create test/mocks/development > > create test/mocks/test > > create test/unit > > create vendor > > create Rakefile > > create README > > create CHANGELOG > > create app/controllers/application.rb > > create app/helpers/application_helper.rb > > create test/test_helper.rb > > create config/database.yml > > create config/routes.rb > > create public/.htaccess > > create config/environment.rb > > create config/environments/production.rb > > create config/environments/development.rb > > create config/environments/test.rb > > create script/console > > create script/destroy > > create script/generate > > create script/server > > create script/runner > > create script/benchmarker > > create script/profiler > > create script/breakpointer > > create public/dispatch.rb > > create public/dispatch.cgi > > create public/dispatch.fcgi > > create public/404.html > > create public/500.html > > create public/index.html > > create public/favicon.ico > > create public/javascripts/prototype.js > > create public/javascripts/effects.js > > create public/javascripts/dragdrop.js > > create public/javascripts/controls.js > > create doc/README_FOR_APP > > create log/server.log > > create log/production.log > > create log/development.log > > create log/test.log > > [root@xsecore html]# cd temp/config > > [root@xsecore config]# cp /var/www/html/frr/config/database.yml . > > cp: overwrite `./database.yml''? y > > [root@xsecore config]# cd .. > > [root@xsecore temp]# script/generate model Person > > exists app/models/ > > exists test/unit/ > > exists test/fixtures/ > > create app/models/person.rb > > create test/unit/person_test.rb > > create test/fixtures/people.yml > > [root@xsecore temp]# cd app > > [root@xsecore app]# cd models > > [root@xsecore models]# more person.rb > > class Person < ActiveRecord::Base > > end > > [root@xsecore models]# vi person.rb > > [root@xsecore models]# cat person.rb > > class Person < ActiveRecord::Base > > def self.table_name() > > "contacts.people" > > end > > > > end > > [root@xsecore models]# cd .. > > [root@xsecore app]# cd .. > > [root@xsecore temp]# script/generate controller Person > > exists app/controllers/ > > exists app/helpers/ > > create app/views/person > > exists test/functional/ > > create app/controllers/person_controller.rb > > create test/functional/person_controller_test.rb > > create app/helpers/person_helper.rb > > [root@xsecore temp]# > > [root@xsecore temp]# ls > > app CHANGELOG components config db doc lib log public Rakefile > > README script test vendor > > [root@xsecore temp]# script/generate scaffold Person > > dependency model > > exists app/models/ > > exists test/unit/ > > exists test/fixtures/ > > skip app/models/person.rb > > skip test/unit/person_test.rb > > skip test/fixtures/people.yml > > exists app/controllers/ > > exists app/helpers/ > > create app/views/people > > exists test/functional/ > > create app/controllers/people_controller.rb > > create test/functional/people_controller_test.rb > > create app/helpers/people_helper.rb > > create app/views/layouts/people.rhtml > > create public/stylesheets/scaffold.css > > create app/views/people/list.rhtml > > create app/views/people/show.rhtml > > create app/views/people/new.rhtml > > create app/views/people/edit.rhtml > > error Before updating scaffolding from new DB schema, try creating > a > > table for your model (Person) > > [root@xsecore temp]# > > Do you have the database all set up? Can you run ''rake'' to run all > the unit tests ok? > > Scaffolding needs access to the database, obviously. > >
On 7/14/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 7/14/05, Andrew Stuart <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> wrote: > > Hi Joe - thanks for helping. > > > > If I add scaffold :person to my controller as follows, then everything seems > > to work okay. > > > > class PersonController < ApplicationController > > model :person > > scaffold :person > > end > > > > I need to modify the code though so it''s not really practical to work with > > the default scaffold, I''d rather generate the code and modify that to my > > needs. > > And running ''rake'' works ok? > > If it does, sounds like the scaffold generator doesn''t know the > table''s actual name (i.e. bug).Although, I found the following comment by DHH at http://dev.rubyonrails.com/ticket/913 : "Scaffolding is reserved for the common case of following all the rules. There are a lot of exceptions we should otherwise think about honoring, like other names for ids for example. I think we''ll just let it rest as a limitation." But it''s odd that it would work when putting :scaffold in the controller, but not being able to generate the code. Perhaps there''s a way to specify the table name as an argument to the scaffold generator?> > > ----- Original Message ----- > > From: "Joe Van Dyk" <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > To: "Andrew Stuart" <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org>; > > <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > > Sent: Friday, July 15, 2005 1:32 PM > > Subject: Re: [Rails] script/generate scaffold problem > > > > > > On 7/14/05, Andrew Stuart <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> wrote: > > > Hello, > > > > > > I asked the community earlier if I should be using the script/generate > > code > > > creation stuff - the answer was yes. So I''m trying to use it to create a > > > scaffold but it doesn''t seem to work. Below is a transcript of creating > > > this application from scratch, finally leading to the error "Before > > updating > > > scaffolding from new DB schema, try creating a table for your model > > > (Person)". > > > > > > Is this happening because I have left the golden path by adding def > > > self.table_name() "contacts.people" end to my model? > > > > > > Does generate only work for the golden path? After going to extensive > > > effort to create a database that is golden path compliant I seem to have > > > ended up on the brown path. > > > > > > Any help much appreciated in advance. here''s the transcript of what I > > did - > > > cheers andrew > > > > > > [root@xsecore html]# rm -rf temp > > > [root@xsecore html]# rails temp > > > create > > > create app/apis > > > create app/controllers > > > create app/helpers > > > create app/models > > > create app/views/layouts > > > create config/environments > > > create components > > > create db > > > create doc > > > create lib > > > create log > > > create public/images > > > create public/javascripts > > > create public/stylesheets > > > create script > > > create test/fixtures > > > create test/functional > > > create test/mocks/development > > > create test/mocks/test > > > create test/unit > > > create vendor > > > create Rakefile > > > create README > > > create CHANGELOG > > > create app/controllers/application.rb > > > create app/helpers/application_helper.rb > > > create test/test_helper.rb > > > create config/database.yml > > > create config/routes.rb > > > create public/.htaccess > > > create config/environment.rb > > > create config/environments/production.rb > > > create config/environments/development.rb > > > create config/environments/test.rb > > > create script/console > > > create script/destroy > > > create script/generate > > > create script/server > > > create script/runner > > > create script/benchmarker > > > create script/profiler > > > create script/breakpointer > > > create public/dispatch.rb > > > create public/dispatch.cgi > > > create public/dispatch.fcgi > > > create public/404.html > > > create public/500.html > > > create public/index.html > > > create public/favicon.ico > > > create public/javascripts/prototype.js > > > create public/javascripts/effects.js > > > create public/javascripts/dragdrop.js > > > create public/javascripts/controls.js > > > create doc/README_FOR_APP > > > create log/server.log > > > create log/production.log > > > create log/development.log > > > create log/test.log > > > [root@xsecore html]# cd temp/config > > > [root@xsecore config]# cp /var/www/html/frr/config/database.yml . > > > cp: overwrite `./database.yml''? y > > > [root@xsecore config]# cd .. > > > [root@xsecore temp]# script/generate model Person > > > exists app/models/ > > > exists test/unit/ > > > exists test/fixtures/ > > > create app/models/person.rb > > > create test/unit/person_test.rb > > > create test/fixtures/people.yml > > > [root@xsecore temp]# cd app > > > [root@xsecore app]# cd models > > > [root@xsecore models]# more person.rb > > > class Person < ActiveRecord::Base > > > end > > > [root@xsecore models]# vi person.rb > > > [root@xsecore models]# cat person.rb > > > class Person < ActiveRecord::Base > > > def self.table_name() > > > "contacts.people" > > > end > > > > > > end > > > [root@xsecore models]# cd .. > > > [root@xsecore app]# cd .. > > > [root@xsecore temp]# script/generate controller Person > > > exists app/controllers/ > > > exists app/helpers/ > > > create app/views/person > > > exists test/functional/ > > > create app/controllers/person_controller.rb > > > create test/functional/person_controller_test.rb > > > create app/helpers/person_helper.rb > > > [root@xsecore temp]# > > > [root@xsecore temp]# ls > > > app CHANGELOG components config db doc lib log public Rakefile > > > README script test vendor > > > [root@xsecore temp]# script/generate scaffold Person > > > dependency model > > > exists app/models/ > > > exists test/unit/ > > > exists test/fixtures/ > > > skip app/models/person.rb > > > skip test/unit/person_test.rb > > > skip test/fixtures/people.yml > > > exists app/controllers/ > > > exists app/helpers/ > > > create app/views/people > > > exists test/functional/ > > > create app/controllers/people_controller.rb > > > create test/functional/people_controller_test.rb > > > create app/helpers/people_helper.rb > > > create app/views/layouts/people.rhtml > > > create public/stylesheets/scaffold.css > > > create app/views/people/list.rhtml > > > create app/views/people/show.rhtml > > > create app/views/people/new.rhtml > > > create app/views/people/edit.rhtml > > > error Before updating scaffolding from new DB schema, try creating > > a > > > table for your model (Person) > > > [root@xsecore temp]# > > > > Do you have the database all set up? Can you run ''rake'' to run all > > the unit tests ok? > > > > Scaffolding needs access to the database, obviously. > > > > >
Hi Joe, Rake falls over and says: 1) Error: test_truth(PersonTest): ActiveRecord::StatementInvalid: ERROR: relation "people" does not exist : DELETE FROM people But I don''t have a relation "people" - I have a relation "contacts.people" which I why I specified table_name() in my model. Andrew
On 7/14/05, Andrew Stuart <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> wrote:> Hi Joe, > > Rake falls over and says: > > 1) Error: > test_truth(PersonTest): > ActiveRecord::StatementInvalid: ERROR: relation "people" does not exist > : DELETE FROM people > > But I don''t have a relation "people" - I have a relation "contacts.people" > which I why I specified table_name() in my model. >Maybe try: class People < AR Model Stuff set_table_name "project" end Instead of the table_name() function?
Joe said:>Although, I found the following comment by DHH at >http://dev.rubyonrails.com/ticket/913 : >"Scaffolding is reserved for the common case of following all the >rules. There are a lot of exceptions we should otherwise think about >honoring, like other names for ids for example. I think we''ll just let >it rest as a limitation."That seems to imply that code generation is out of the question for any database that doesn''t follow the golden path. That''s a pity when the community recently put forward some strong arguments for using Rails code generation. So I must live with it. So the question is, what do I do now? How does a newbie build a non golden-path application without having generated code to dig around in and try to understand and extend? What''s the Best Practice/accepted way of moving forward? What do the Rails pros do when they can''t generate code using the script/generate stuff? Cheers and thanks in advance Andrew
"Andrew Stuart" <andrew.stuart-TWq/lk6o2i4FZYWR8B6FNDvXrrhHudLZEK66K81epY8@public.gmane.org> writes:> What''s the Best Practice/accepted way of moving forward? What do the > Rails pros do when they can''t generate code using the > script/generate stuff?Open up a text editor with some generated code in one window and start coding what will work in another window. It might be helpful to work through one or two of the tutorials. With that you''ll have a simple and "golden path" application sitting on your hard drive to look at for reference. You can use that as a launching point to see what to change to fit your situation. -- doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.org
Andrew Stuart wrote:> Hello, > > I asked the community earlier if I should be using the script/generate code > creation stuff - the answer was yes. So I''m trying to use it to create a > scaffold but it doesn''t seem to work. Below is a transcript of creating > this application from scratch, finally leading to the error "Before updating > scaffolding from new DB schema, try creating a table for your model > (Person)". > > Is this happening because I have left the golden path by adding def > self.table_name() "contacts.people" end to my model? > > Does generate only work for the golden path? After going to extensive > effort to create a database that is golden path compliant I seem to have > ended up on the brown path. > > Any help much appreciated in advance. here''s the transcript of what I did - > cheers andrew >[snip] you can add schema_search_path: contacts in config/database.yml for each db config (production, development and test). This will do a "SET search_path TO contacts" in your postgresql database. This way you don''t need to mention the schema name to rails with table_name(), as postgresql will find the table by itself by following the search_path (obviously, if you have two tables called people in different schemas, this won''t work). Does anybody know where this is documented? I found it when browsing the code for the postgresql adapter... regards, Bas