Forum: Ruby on Rails rake aborted! undefined method `empty?' for nil:NilClass

13d7a3ab12ec57e0d372d7115362cb91?d=identicon&s=25 comopasta Gr (comopasta)
on 2009-04-04 23:21
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:in `scan'
/usr/lib/ruby/1.8/erb.rb:525:in `compile'
/usr/lib/ruby/1.8/erb.rb:692:in `initialize'
/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:in
`compile'
/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:in
`__send__'
/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:in
`each'
/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:in
`freeze'
/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:in
`templates_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:in
`templates_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:in
`load'
/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:in
`each'
/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:in
`load_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:in `send'
/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:in
`gem_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:in
`require'
/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:in
`require'
/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:in `execute'
/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:in `execute'
/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:in `synchronize'
/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:in
`invoke_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:in
`invoke_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:in `synchronize'
/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:in `invoke'
/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:in `top_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:in `top_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:in `top_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:in
`standard_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:in `load'
/usr/bin/rake:19
B09a3f6cdc4797532647d2d264b5df49?d=identicon&s=25 Jodi Showers (jshow)
on 2009-04-04 23:32
(Received via mailing list)
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
13d7a3ab12ec57e0d372d7115362cb91?d=identicon&s=25 comopasta Gr (comopasta)
on 2009-04-04 23:51
> 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.
B09a3f6cdc4797532647d2d264b5df49?d=identicon&s=25 Jodi Showers (jshow)
on 2009-04-04 23:56
(Received via mailing list)
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
B09a3f6cdc4797532647d2d264b5df49?d=identicon&s=25 Jodi Showers (jshow)
on 2009-04-05 00:00
(Received via mailing list)
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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-05 01:36
(Received via mailing list)
On Apr 4, 10:21 pm, comopasta Gr <rails-mailing-l...@andreas-s.net>
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
13d7a3ab12ec57e0d372d7115362cb91?d=identicon&s=25 comopasta Gr (comopasta)
on 2009-04-06 23:22
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-|
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2009-04-07 11:38
(Received via mailing list)
Have you tried going back to the previous version (that worked) and then
moving forward again?

2009/4/6 comopasta Gr <rails-mailing-list@andreas-s.net>
36e6e719c742ff0b7231e673a3019c2c?d=identicon&s=25 Ruby Rails (Guest)
on 2009-04-07 11:54
(Received via mailing list)
Do you read rails documentation properly.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-07 12:19
(Received via mailing list)
On Apr 6, 10:22 pm, comopasta Gr <rails-mailing-l...@andreas-s.net>
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
13d7a3ab12ec57e0d372d7115362cb91?d=identicon&s=25 comopasta Gr (comopasta)
on 2009-04-07 14:07
>>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.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-07 14:53
(Received via mailing list)
On Apr 7, 1:07 pm, comopasta Gr <rails-mailing-l...@andreas-s.net>
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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.