Issue with form_for in latest merb_helpers
Reported by rajasaurus | August 16th, 2008 @ 01:18 AM | in 1.0
merb_helpers breaks form_for in commit 3c57a1795a00ac28f50037dcaa9dc24ddf54813b It works in commit e258e56ddc55cf1491b84c2476449e6a5e6bf3ed
The error is below:
~ undefined method `new' for nil:NilClass - (NoMethodError)
/opt/local/lib/ruby/gems/1.8/gems/merb_helpers-0.9.5/lib/merb_helpers/form/helpers.rb:41:in `_singleton_form_context'
/opt/local/lib/ruby/gems/1.8/gems/merb_helpers-0.9.5/lib/merb_helpers/form/helpers.rb:49:in `current_form_context'
/opt/local/lib/ruby/gems/1.8/gems/merb_helpers-0.9.5/lib/merb_helpers/form/helpers.rb:58:in `_new_form_context'
/opt/local/lib/ruby/gems/1.8/gems/merb_helpers-0.9.5/lib/merb_helpers/form/helpers.rb:63:in `with_form_context'
/opt/local/lib/ruby/gems/1.8/gems/merb_helpers-0.9.5/lib/merb_helpers/form/helpers.rb:101:in `form_for'
/Users/raja/Sites/junto/app/views/users/new.html.haml:4:in.....
Comments and changes to this ticket
-
Michael Klishin (antares) August 16th, 2008 @ 01:21 AM
- → Assigned user changed from Michael Klishin (antares) to GMFlash
- → Milestone changed from to 0.9.5
- → State changed from new to open
require 'merb_helpers' in spec helper or the context you use helpers solves it. But it still looks like a bug to me.
-

GMFlash August 19th, 2008 @ 09:02 AM
rajasaurus, can you explain this issue further? I don't really understand the error or how to reproduce it.
-
Michael Klishin (antares) August 26th, 2008 @ 02:01 AM
- → Milestone changed from 0.9.5 to 0.9.6
-

GMFlash August 26th, 2008 @ 03:13 AM
- → Assigned user changed from GMFlash to Yehuda Katz (wycats)
-
Bryan Ray August 26th, 2008 @ 04:46 AM
- → Assigned user changed from Yehuda Katz (wycats) to GMFlash
After a lot of debugging ... (Thanks for the tip, Antares) ...
This has to do with an ActiveSupport load issue. I currently have the same problem and I've tried moving my "merb_helpers" dependency to the bottom of my dependency list ... I've tried moving it in to an after_app_loads block none of which has helped ...
The attached patch solves the problem, but I admit it is more of a hack than a patch.
Does anyone else have any other suggestions?
-
Bryan Ray August 26th, 2008 @ 04:47 AM
ps ... if you want to recreate the issue. You should be able to do:
dependency 'activesupport' anywhere in your init.rb file and your forms will blow up with this error.
-
Michael Klishin (antares) August 27th, 2008 @ 12:39 AM
so what's resolution on this? looks like we found the root of the problem
-
Bryan Ray August 27th, 2008 @ 12:55 AM
I'm not entirely sure there's much that can be done aside from the patch.
The only options I see are:
- Rename the class_inheritable_accessor method so that ActiveSupport doesn't interfere with it
- Figure out how to ensure that Extlib's #c_i_a method loads after ActiveSupport's
- Get ActiveSupport to change their method (probably not happening)
Would love to hear some others though.
-

rajasaurus August 27th, 2008 @ 12:56 AM
class Merb::Controller # form helpers weren't propagating form_class through properly # so it was showing up nil. See lighthouse ticket for updates: # http://merb.lighthouseapp.com/pr... def form_class
Merb::Helpers::Form::Builder::ResourcefulFormWithErrorsend end
-

rajasaurus August 27th, 2008 @ 12:57 AM
sorry...
class Merb::Controller # form helpers weren't propagating _form_class through properly # so it was showing up nil. See lighthouse ticket for updates: # http://merb.lighthouseapp.com/projects/7588/tickets/144-issue-with-form_for-in-latest-merb_helpers def _form_class Merb::Helpers::Form::Builder::ResourcefulFormWithErrors end end -
Matthijs Langenberg August 27th, 2008 @ 09:47 PM
Rajasarous, thanks for posting the monkeypatch. At least I can go on working on my app now. Just want to let you guys know that this problem arises at every place where class_inheritable_accessor is being used. For example, merb-mailer uses it for Merb::Mailer.config.
-
Matthijs Langenberg August 28th, 2008 @ 11:11 AM
Can't we namespace class_inheritable_accessor like so:
class Merb::Mailer Extlib::class_inheritable_accessor(self, :config) endclass Merb::Controller Extlib::class_inheritable_accessor(self, :_form_class) end -
-
Matthijs Langenberg August 29th, 2008 @ 10:26 AM
After having some discussion in the IRC channel last night, does everyone agree on the following syntax?
class Merb::Mailer extend Extlib::ClassMethods class_inheritable_accessor(:config) endclass Merb::Controller extend Extlib::ClassMethods class_inheritable_accessor(:_form_class) end -
Michael Klishin (antares) August 29th, 2008 @ 12:19 PM
Matthijs,
Brilliant idea. We had 3 or 4 others in that IRC discussion, this on is the best.
-

GMFlash September 6th, 2008 @ 03:32 AM
- → Assigned user changed from GMFlash to Yehuda Katz (wycats)
- → Tag changed from merb_helpers to bug extlib form_helpers merb-plugins merb_helpers
Since this is an extlib issue I am reassigning to Yehuda.
-
Michael Klishin (antares) September 9th, 2008 @ 02:22 AM
- → Milestone changed from 0.9.6 to 0.9.7
-
Michael Klishin (antares) September 14th, 2008 @ 02:08 AM
- → Milestone changed from 0.9.7 to 0.9.8
-
Matthijs Langenberg September 15th, 2008 @ 03:05 PM
Is the Extlib implementation of c_i_a already merged into Rails? If not, what is the next step to solve this issue? There are already a few possible solutions, but if I'm right, there hasn't been a formal decision or action.
-
Bryan Ray September 15th, 2008 @ 05:04 PM
So, technically, this issue has already been resolved (for the Form Helpers specifically) by a small little monkey patch:
http://github.com/wycats/merb-pl...
but ... I would agree that something needs to be done more "permanently" to fix the larger issue.
-
Michael Klishin (antares) September 15th, 2008 @ 06:05 PM
No, someone has to come up with the patch for Rails.
-
Michael Klishin (antares) October 7th, 2008 @ 11:59 AM
- → Assigned user changed from Yehuda Katz (wycats) to Michael Klishin (antares)
- → Tag changed from bug extlib form_helpers merb-plugins merb_helpers to bug extlib form_helpers "merb-plugins" merb_helpers
- → Milestone changed from 0.9.8 to 1.0
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
