Rake aborted! undefined method `empty?' for nil:NilClass


#1

Hi,

I’m getting the next errors, would anyone have any suggestions?

Thanks.

[~/rails/hip]# rake --trace db:migrate RAILS_ENV=“production”
(in /home/domain/rails/hip)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method empty?' for nil:NilClass /usr/lib/ruby/1.8/erb.rb:469:inscan’
/usr/lib/ruby/1.8/erb.rb:525:in compile' /usr/lib/ruby/1.8/erb.rb:692:ininitialize’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template_handlers/erb.rb:51:in
new' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template_handlers/erb.rb:51:incompile’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template_handler.rb:11:in
call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:21:in_unmemoized_compiled_source’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/memoizable.rb:57:in
compiled_source' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/memoizable.rb:25:insend
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/memoizable.rb:25:in
memoize_all' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/memoizable.rb:22:ineach’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/memoizable.rb:22:in
memoize_all' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/memoizable.rb:17:infreeze’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:88:in
reload!' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:102:intemplates_in_path’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:100:in
each' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:100:intemplates_in_path’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:86:in
reload!' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:78:inload’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:109:in
load' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:109:ineach’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/paths.rb:109:in
load' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:357:inload_view_paths’
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:182:in
process' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:insend’
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in run' /home/domain/rails/hip/config/environment.rb:15 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in
new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:inrequire’
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/misc.rake:3
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in call' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:inexecute’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in each' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:inexecute’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in
invoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:insynchronize’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in
invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:588:ininvoke_prerequisites’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in each' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:ininvoke_prerequisites’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:577:in
invoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:insynchronize’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in
invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:ininvoke’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in invoke_task' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:intop_level’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in each' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:intop_level’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:intop_level’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:instandard_exception_handling’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31 /usr/bin/rake:19:inload’
/usr/bin/rake:19


#2

On 4-Apr-09, at 5:21 PM, comopasta Gr wrote:

Hi,

I’m getting the next errors, would anyone have any suggestions?

Thanks.

/home/domain/rails/hip/config/environment.rb:15

what’s on line 15 of your config/environment.rb ?

Jodi


#3

what’s on line 15 of your config/environment.rb ?

Hi, yeah I was looking at that as well.

This is the line: config.active_record.observers = :user_observer
Commenting it out didn’t make a difference…

Regards.


#4

On 4-Apr-09, at 5:51 PM, comopasta Gr wrote:

what’s on line 15 of your config/environment.rb ?

Hi, yeah I was looking at that as well.

This is the line: config.active_record.observers = :user_observer
Commenting it out didn’t make a difference…

you restarted after commenting it out? the env is loaded once.

Jodi


#5

On Apr 4, 10:21 pm, comopasta Gr removed_email_address@domain.invalid
wrote:

** Execute environment
`call’
From this part of the stack trace it looks likes it’s happening when
it preloads your view templates, maybe a template with something funny
in it ?

Fred


#6

On 4-Apr-09, at 5:51 PM, comopasta Gr wrote:

what’s on line 15 of your config/environment.rb ?

Hi, yeah I was looking at that as well.

This is the line: config.active_record.observers = :user_observer
Commenting it out didn’t make a difference…

forget my last comment. forgot it was a rake task - but you must have
a different stack trace though…

J


#7

Hi,

I’m thinking of re-creating the whole app completely. It is not public
yet. But I don’t get this error.

On the site I just get “Application error Rails application failed to
start properly”. And then those “undefined method `empty?’ for
nil:NilClass”

Everything was just working fine, the only things I did when all that
started was a very simple change to a controller, changing a css class
to a template (not a new css class, an existing one already). The only
out of the normal I did was running migrate to add this line to a table:

execute “alter table attachments add constraint fk_messages foreign key
(message_id) references messages(id) ON DELETE CASCADE”

That was commented out and I removed the # to run the migrate. But that
is working fine with my local environment.

Looks like Rails can be very cryptic when it comes to debugging these
type of issues…

Like I said thinking of re-creating the whole thing again to see if it
goes ok.

Cheers x-|


#8

Do you read rails documentation properly.


#9

On Apr 6, 10:22 pm, comopasta Gr removed_email_address@domain.invalid
wrote:

That was commented out and I removed the # to run the migrate. But that
is working fine with my local environment.

I bet that if you set config.cache_classes = true in development.rb
then you’ll get this issue locally, which should make it easier to
diagnose.

Fred


#10

Have you tried going back to the previous version (that worked) and then
moving forward again?

2009/4/6 comopasta Gr removed_email_address@domain.invalid


#11

Have you tried going back to the previous version (that worked) and then
moving forward again?

I did, no help.

Do you read rails documentation properly.
Klingons said: “specs are for the weak and the timid”
Sniff. Yes and no to your question. My RoR focus time is between 10:30
PM to 01:00 AM every “day”, I jump in straight to the code. I must admit
that I should do better. However I do really use the documentation
frequently, this time I didn’t know were to start actually. Of course
the fact that I read it doesn’t mean that I understand it, I try at
least before requesting help from you guys.

I bet that if you set config.cache_classes = true in development.rb
then you’ll get this issue locally, which should make it easier to
diagnose.

I won’t ever bet anything with you Fred. I set that to false and now it
works fine. I have been running migrations and made all sort of changes
for a long time with that set to true and it has been ok. But now it
really hit me.

Thanks so much to all for your help guys!

Cheers.


#12

On Apr 7, 1:07 pm, comopasta Gr removed_email_address@domain.invalid
wrote:

I bet that if you set config.cache_classes = true in development.rb
then you’ll get this issue locally, which should make it easier to
diagnose.

I won’t ever bet anything with you Fred. I set that to false and now it
works fine. I have been running migrations and made all sort of changes
for a long time with that set to true and it has been ok. But now it
really hit me.

That setting should absolutely be set to true or your production site
will running a lot slower. I was merely suggesting that playing with
that would allow you to reproduce the problem on your local machine.
One of the things that setting does is make models, controllers, views
etc. be loaded at start time (rather than on demand) and a side effect
of that is that views or models you don’t use will get loaded anyway,
so an error in code that you never actually call or a view that you
never display can still hit you

Fred