views:

228

answers:

1

Argh! Everything has been totally fine, then all of a sudden I started getting this error when I was doing a 'rake db:migrate' And I get the same thing when I try to restart the rails server.

rake aborted!
undefined method 'form_for' for module `ActionView::Helpers::FormHelper'

Confirmation that I'm running a current version: mm-MacBookPro:trunk mm$ rails -v Rails 2.3.5

None of my form_for's were added recently and they were working fine. I rebooted and reinstalled rails. What the heck could cause this?

Here's the --trace

** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! undefined method form_for' for module ActionView::Helpers::FormHelper' /Users/mm/.gem/ruby/1.9.1/gems/haml-2.2.19/lib/haml/helpers/action_view_mods.rb:174:in alias_method' /Users/mm/.gem/ruby/1.9.1/gems/haml-2.2.19/lib/haml/helpers/action_view_mods.rb:174:in ' /Users/mm/.gem/ruby/1.9.1/gems/haml-2.2.19/lib/haml/helpers/action_view_mods.rb:159:in <module:Helpers>' /Users/mm/.gem/ruby/1.9.1/gems/haml-2.2.19/lib/haml/helpers/action_view_mods.rb:41:in ' /Users/mm/.gem/ruby/1.9.1/gems/haml-2.2.19/lib/haml/helpers/action_view_mods.rb:1:in <top (required)>' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in block in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Users/mm/.gem/ruby/1.9.1/gems/haml-2.2.19/lib/haml/helpers.rb:2:in ' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in block in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Users/mm/.gem/ruby/1.9.1/gems/haml-2.2.19/lib/haml/engine.rb:1:in <top (required)>' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in block in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Users/mm/.gem/ruby/1.9.1/gems/haml-2.2.19/lib/haml.rb:40:in' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in block in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Volumes/Development/tc/app/trunk/vendor/plugins/haml/init.rb:5:in rescue in block in evaluate_init_rb' /Volumes/Development/tc/app/trunk/vendor/plugins/haml/init.rb:1:in block in evaluate_init_rb' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/rails/plugin.rb:146:in eval' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/rails/plugin.rb:146:in block in evaluate_init_rb' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in silence_warnings' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/rails/plugin.rb:142:in evaluate_init_rb' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/rails/plugin.rb:48:in load' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/rails/plugin/loader.rb:38:in block in load_plugins' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/rails/plugin/loader.rb:37:in each' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/rails/plugin/loader.rb:37:in load_plugins' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/initializer.rb:348:in load_plugins' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/initializer.rb:163:in process' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/initializer.rb:113:in run' /Volumes/Development/tc/app/trunk/config/environment.rb:13:in ' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in block in require' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' /Volumes/Development/tc/app/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /Volumes/Development/tc/app/trunk/vendor/rails/railties/lib/tasks/misc.rake:4:in block in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:incall' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in block in execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:ineach' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:inblock in invoke_with_call_chain' /usr/local/lib/ruby/1.9.1/monitor.rb:190:in mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:607:in block in invoke_prerequisites' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:ineach' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in invoke_prerequisites' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:596:inblock in invoke_with_call_chain' /usr/local/lib/ruby/1.9.1/monitor.rb:190:in mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:in invoke' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in block (2 levels) in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in block in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:in block in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake:31:in <top (required)>' /usr/local/bin/rake:19:inload' /usr/local/bin/rake:19:in `'

+1  A: 

This is strange. HAML is fighting with ActionView for some reason. It looks like HAML is loaded before ActionView? Do you have any strange requires in for HAML in your application?

Have you tried upgrading your HAML gem? Could you also try to disable the plugin in config/environment.rb, and then run your rake task?

If you're not using HAML at all, then you could also remove the plugin from vendor/plugins.

Shtééf
I didn't add any requires recently, so I'm at a loss as to what started this. I was doing a few migrations when this started happening -- I was just renaming tables and some classes.'haml' is not listed in config/environment.rb so I'm not sure how to disable it. I reinstalled haml, and ran update on it, but it says there's nothing to update.I am using haml, so i don't want to remove the plugin.
99miles
In that case, am I correct in saying you don't have a `config.plugins` line in `config/environment.rb` at all? That'd mean it just loads all plugins. Even if you do want to use HAML, could you try moving the `vendor/plugins/haml` directory aside, and seeing if `rake db:migrate` works? That way, we'll can at least say for sure that HAML is causing it.
Shtééf
OK, I moved it out and the migrate worked!So, the next step would be...?
99miles
Good question. :) I'm not seeing this problem locally. Perhaps you can edit the question and paste a full trace?
Shtééf
Well, I'm stumped. I can only give you some more guesswork here. Could you try unfreezing Rails from your app? (`rake rails:unfreeze`) Or reinstall the HAML plugin?
Shtééf
Reinstalling HAML didn't help.I unfroze rails and got:Missing the Rails 2.3.2 gem. Please `gem install -v=2.3.2 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.-So I commented out that line and migrate worked.-Then I uncommented that line and got the same 'Missing the Rails 2.3.2 gem' error again. So I ran 'gem install -v=2.3.2 rails'Now the migrate works. I'm not really clear on what unfreezing rails exactly does. Should I freeze it again, or?
99miles
I just did 'rake rails:freeze:edge RELEASE=2.3.2' and everything seems ok so far! What the heck??I have no idea what just happened, but thank you so much!
99miles
Freezing basically installs the Rails gem along with your application, in `vendor/rails`. Looks like somehow, the version of Rails installed there was broken.
Shtééf