Hello, I''m writing a Rails application on my home computer. I update it from time to time to a demo server. The demo server complains a lot, while I didn''t have any problems at home. Whenever I iterate over an empty collection, like : controller: @keyword_groups = KeywordGroup.find(:all) view: <%= render :partial => "keyword_group", :collection => @keyword_groups %> partial: <%= link_to keyword_group.label, :action => ''show_keyword_group'', :id => keyword_group %> If the keyword_groups table is empty, this works fine at home, but doesn''t work on the demo server: ActionView::TemplateError (undefined method `label'' for nil:NilClass) on line #4 of app/views/user/_keyword_group.rhtml: I''d like to be sure my app will work anywhere, so how can I make my development environment as much strict as the demo one? Is that just a configuration option? Thanks, Karine Delvare --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karine Delvare wrote:> Hello, > > I''m writing a Rails application on my home computer. I update it from > time to time to a demo server. > > The demo server complains a lot, while I didn''t have any problems at > home. Whenever I iterate over an empty collection, like : > > controller: > @keyword_groups = KeywordGroup.find(:all) > > view: > <%= render :partial => "keyword_group", :collection => @keyword_groups > %> > > partial: > <%= link_to keyword_group.label, :action => ''show_keyword_group'', :id > => keyword_group %> > > If the keyword_groups table is empty, this works fine at home, but > doesn''t work on the demo server: > > ActionView::TemplateError (undefined method `label'' for nil:NilClass) > on line #4 of app/views/user/_keyword_group.rhtml: > > I''d like to be sure my app will work anywhere, so how can I make my > development environment as much strict as the demo one? Is that just a > configuration option? > > Thanks, > Karine DelvareThere''s an environment config parameter called "config.whiny_nils". By default in your config/environments/development.rb file you''ll see it set to "true". It looks like your home machine is running in production mode but your demo server is running in development mode. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karine Delvare
2007-Sep-19 16:21 UTC
Re: Demo environment more strict than development one
On Wed, 19 Sep 2007 01:12:23 -0700 Michael Wang <rails-user-JtyympAsP2K7zZZRDBGcUA@public.gmane.org> wrote:> There''s an environment config parameter called "config.whiny_nils". > By default in your config/environments/development.rb file you''ll see > it set to "true". It looks like your home machine is running in > production mode but your demo server is running in development mode.Thanks for your answer. Home is in development mode and Demo in production mode. They share the same config/ folder, where I indeed found config.whiny_nils = true in development.rb And I found out that home is as strict as demo, and throws the nil error to me when it stumbles upon it. So, the strictness problem wasn''t there, everything is configured fine, but I had just witnessed something strange on the demo server, that happened today on the home server, and that I just don''t understand... I created a new model. New methods in my old controller to manage it, new views, new partials. And same error when trying to render the partial on the empty collection (this time the error did happen on my home server so I could verify that it is indeed as strict as demo). The very strange thing is that, if in the partial I replace: <%= link_to book.title, :action => ''show_book'', :id => book %> with: <%= link_to book.title, :action => ''show_book'', :id => book if book %> there is no more nil error for sure, but I see an empty partial (there is a static image in that partial, and I see one in the view where I render the partial on the @books collection) while the @books collection is empty (I checked its length, it is 0). How can that happen? Thanks, Karine Delvare --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Karine Delvare
2007-Sep-20 07:58 UTC
Re: Demo environment more strict than development one
On Wed, 19 Sep 2007 18:21:23 +0200 Karine Delvare <kdelvare-T/o0Z7lmwKpeoWH0uzbU5w@public.gmane.org> wrote:> there is no more nil error for sure, but I see an empty partial (there > is a static image in that partial, and I see one in the view where I > render the partial on the @books collection) while the @books > collection is empty (I checked its length, it is 0). How can that > happen?Forget it, I''m stupid for sure, typo in the collection name.... Everything is fixed :) Karine Delvare --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---