Demo environment more strict than development one

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 D.

Karine D. wrote:

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 D.

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.


Michael W.

On Wed, 19 Sep 2007 01:12:23 -0700
Michael W. [email protected] 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 D.

On Wed, 19 Sep 2007 18:21:23 +0200
Karine D. [email protected] 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 :slight_smile:

Karine D.