genterminl
2011-Oct-17 23:39 UTC
difference in generate scaffold files with different rails versions
I''ve found a difference in the files created by "./script/rails generate scaffold Model xxx" with rails 2.3.14 and "./script/generate scaffold Model xxx" with rails 3.0.10 that doesn''t make sense to me. (both with ruby 1.8.7 on Gentoo Linux) With 2.3.14, near the beginning of app/controllers/xxxes_controller.rb is the line "@xxxes = Xxx.all" and a few lines later "format.xml { render :xml => @xxxes }" With 3.0.10, the first is "@xxx Xxx.all" and the second is has @xxx instead of @xxxes. All other references to xxx or xxxes are the same in both versions. This causes problems with 3.0.10, because app/views/xxxes/index.html.erb includes the line "<% @xxxes.each do |xxx| %>" which causes a nil object error. I''ve done plenty of searching, but haven''t found anything relevant. Is this a bug, a feature, a side effect of misusing the scaffold generator, ....? Most if not all of the docs and tutorials I''ve found are not specific about which version of rails they are base on. Pointers to the right fine manual to read are also welcome, as I''m still pretty new with both ruby and rails. Thanks for any assistance. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Oct-18 10:17 UTC
Re: difference in generate scaffold files with different rails versions
On Oct 18, 12:39 am, genterminl <ostrof...-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> wrote:> I''ve found a difference in the files created by "./script/rails > generate scaffold Model xxx" with rails 2.3.14 and "./script/generate > scaffold Model xxx" with rails 3.0.10 that doesn''t make sense to me. > (both with ruby 1.8.7 on Gentoo Linux)Is xxx what you are actually typing or just a placeholder? If it''s the former, then the difference is probably the set of inflections rails users to pluralize xxx, which i think has changed somewhere between 2.x and 3.x. With some words, you can get situations where taking a word, pluralizing it and then singularizing it again doesn''t get you the original word, which occasionally leads to trouble. I would expect things to work properly with a word that was a more normal name for a model. Fred> > With 2.3.14, near the beginning of app/controllers/xxxes_controller.rb > is the line "@xxxes = Xxx.all" and a few lines later "format.xml > { render :xml => @xxxes }" With 3.0.10, the first is "@xxx > Xxx.all" and the second is has @xxx instead of @xxxes. All other > references to xxx or xxxes are the same in both versions. This causes > problems with 3.0.10, because app/views/xxxes/index.html.erb includes > the line "<% @xxxes.each do |xxx| %>" which causes a nil object error. > > I''ve done plenty of searching, but haven''t found anything relevant. > Is this a bug, a feature, a side effect of misusing the scaffold > generator, ....? Most if not all of the docs and tutorials I''ve found > are not specific about which version of rails they are base on. > Pointers to the right fine manual to read are also welcome, as I''m > still pretty new with both ruby and rails. > > Thanks for any assistance.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
genterminl
2011-Oct-18 20:52 UTC
Re: difference in generate scaffold files with different rails versions
On Oct 18, 6:17 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 18, 12:39 am, genterminl <ostrof...-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> wrote: > > > I''ve found a difference in the files created by "./script/rails > > generate scaffold Model xxx" with rails 2.3.14 and "./script/generate > > scaffold Model xxx" with rails 3.0.10 that doesn''t make sense to me. > > (both with ruby 1.8.7 on Gentoo Linux) > > Is xxx what you are actually typing or just a placeholder? If it''s the > former, then the difference is probably the set of inflections rails > users to pluralize xxx, which i think has changed somewhere between > 2.x and 3.x. With some words, you can get situations where taking a > word, pluralizing it and then singularizing it again doesn''t get you > the original word, which occasionally leads to trouble. I would expect > things to work properly with a word that was a more normal name for a > model. > > > With 2.3.14, near the beginning of app/controllers/xxxes_controller.rb > > is the line "@xxxes = Xxx.all" and a few lines later "format.xml > > { render :xml => @xxxes }" With 3.0.10, the first is "@xxx > > Xxx.all" and the second is has @xxx instead of @xxxes. All other > > references to xxx or xxxes are the same in both versions. This causes > > problems with 3.0.10, because app/views/xxxes/index.html.erb includes > > the line "<% @xxxes.each do |xxx| %>" which causes a nil object error. >I have the same problem with xxx (done literally as a test) but also "region" and "person." However, in the "person" case, both versions of app/views/people/index.html.erb have @people.each, but in app/ controllers/people_controller.rb the rails 2 version has @person person.all but the rails 3 version has @people = person.all. Both versions have "people" elsewhere in the file - so it''s not just a change in how it pluralizes, it''s a change in where it uses the plural or not. NOTE: I think my original message had it backwards. (It''s confusing trying to keep two apps strait using different versions of rails...) The rails 2 scaffold causes a problem with the mismatch, the rails 3 version is consistent, so it works. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.