Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Custom Inputs not found, V 2.02, Ruby 1.9.3 #809

Closed
rhulse opened this Issue Feb 23, 2012 · 7 comments

Comments

Projects
None yet
3 participants

rhulse commented Feb 23, 2012

I have some custom inputs which stop working when updating the app to ruby 1.9.3:

Formtastic::UnknownInputError

Al the app's specs pass. On the surface it looks like they are not loading.

Owner

justinfrench commented Feb 23, 2012

Can we see a full stack trace? Did this exact code work on another ruby version?

rhulse commented Feb 23, 2012

Yes, it worked fine on 1.8.7. Here is the stack trace:

(It is the custom wysiwyg that is causing the error)

ActionView::Template::Error (Formtastic::UnknownInputError):
1: <%= form.inputs :class => 'group' do -%>
2: <%= form.input :name %>
3: <%= form.input :contacts, {:as => :wysiwyg} %>
4: <%= form.input :notes, {:as => :wysiwyg} %>
5: <%- end -%>
formtastic (2.0.2) lib/formtastic/helpers/input_helper.rb:353:in rescue in input_class' formtastic (2.0.2) lib/formtastic/helpers/input_helper.rb:345:ininput_class'
formtastic (2.0.2) lib/formtastic/helpers/input_helper.rb:265:in input' app/views/people/_form.html.erb:2:inblock in _app_views_people__form_html_erb___2877491542180097044_70235883284760'
actionpack (3.2.1) lib/action_view/helpers/capture_helper.rb:40:in block in capture' actionpack (3.2.1) lib/action_view/helpers/capture_helper.rb:187:inwith_output_buffer'
actionpack (3.2.1) lib/action_view/helpers/capture_helper.rb:40:in capture' formtastic (2.0.2) lib/formtastic/helpers/fieldset_wrapper.rb:36:infield_set_and_list_wrapping'
formtastic (2.0.2) lib/formtastic/helpers/inputs_helper.rb:292:in inputs' app/views/people/_form.html.erb:1:in_app_views_people__form_html_erb___2877491542180097044_70235883284760'
actionpack (3.2.1) lib/action_view/template.rb:143:in block in render' activesupport (3.2.1) lib/active_support/notifications.rb:125:ininstrument'
actionpack (3.2.1) lib/action_view/template.rb:141:in render' actionpack (3.2.1) lib/action_view/renderer/partial_renderer.rb:257:inrender_partial'
actionpack (3.2.1) lib/action_view/renderer/partial_renderer.rb:230:in block in render' actionpack (3.2.1) lib/action_view/renderer/abstract_renderer.rb:38:inblock in instrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in block in instrument' activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.1) lib/action_view/renderer/abstract_renderer.rb:38:ininstrument'
actionpack (3.2.1) lib/action_view/renderer/partial_renderer.rb:229:in render' actionpack (3.2.1) lib/action_view/renderer/renderer.rb:41:inrender_partial'
actionpack (3.2.1) lib/action_view/helpers/rendering_helper.rb:27:in render' app/views/people/new.html.erb:3:inblock in _app_views_people_new_html_erb___3090460013784159554_70235902641000'
actionpack (3.2.1) lib/action_view/helpers/capture_helper.rb:40:in block in capture' actionpack (3.2.1) lib/action_view/helpers/capture_helper.rb:187:inwith_output_buffer'
actionpack (3.2.1) lib/action_view/helpers/capture_helper.rb:40:in capture' actionpack (3.2.1) lib/action_view/helpers/form_helper.rb:606:infields_for'
actionpack (3.2.1) lib/action_view/helpers/form_helper.rb:377:in form_for' formtastic (2.0.2) lib/formtastic/helpers/form_helper.rb:161:inblock in semantic_form_for'
formtastic (2.0.2) lib/formtastic/helpers/form_helper.rb:192:in with_custom_field_error_proc' formtastic (2.0.2) lib/formtastic/helpers/form_helper.rb:160:insemantic_form_for'
app/views/people/new.html.erb:3:in _app_views_people_new_html_erb___3090460013784159554_70235902641000' actionpack (3.2.1) lib/action_view/template.rb:143:inblock in render'
activesupport (3.2.1) lib/active_support/notifications.rb:125:in instrument' actionpack (3.2.1) lib/action_view/template.rb:141:inrender'
actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:41:in block (2 levels) in render_template' actionpack (3.2.1) lib/action_view/renderer/abstract_renderer.rb:38:inblock in instrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in block in instrument' activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.1) lib/action_view/renderer/abstract_renderer.rb:38:ininstrument'
actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:40:in block in render_template' actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:48:inrender_with_layout'
actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:39:in render_template' actionpack (3.2.1) lib/action_view/renderer/template_renderer.rb:12:inrender'
actionpack (3.2.1) lib/action_view/renderer/renderer.rb:36:in render_template' actionpack (3.2.1) lib/action_view/renderer/renderer.rb:17:inrender'
actionpack (3.2.1) lib/abstract_controller/rendering.rb:109:in _render_template' actionpack (3.2.1) lib/action_controller/metal/streaming.rb:225:in_render_template'
actionpack (3.2.1) lib/abstract_controller/rendering.rb:103:in render_to_body' actionpack (3.2.1) lib/action_controller/metal/renderers.rb:28:inrender_to_body'
actionpack (3.2.1) lib/action_controller/metal/compatibility.rb:50:in render_to_body' actionpack (3.2.1) lib/abstract_controller/rendering.rb:88:inrender'
actionpack (3.2.1) lib/action_controller/metal/rendering.rb:16:in render' actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:40:inblock (2 levels) in render'
activesupport (3.2.1) lib/active_support/core_ext/benchmark.rb:5:in block in ms' /Users/rhulse/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/benchmark.rb:295:inrealtime'
activesupport (3.2.1) lib/active_support/core_ext/benchmark.rb:5:in ms' actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:40:inblock in render'
actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:83:in cleanup_view_runtime' activerecord (3.2.1) lib/active_record/railties/controller_runtime.rb:24:incleanup_view_runtime'
sunspot_rails (1.3.0) lib/sunspot/rails/railties/controller_runtime.rb:15:in cleanup_view_runtime' actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:39:inrender'
actionpack (3.2.1) lib/action_controller/metal/implicit_render.rb:10:in default_render' actionpack (3.2.1) lib/action_controller/metal/mime_responds.rb:268:inblock in retrieve_response_from_mimes'
actionpack (3.2.1) lib/action_controller/metal/mime_responds.rb:195:in call' actionpack (3.2.1) lib/action_controller/metal/mime_responds.rb:195:inrespond_to'
app/controllers/people_controller.rb:45:in new' actionpack (3.2.1) lib/action_controller/metal/implicit_render.rb:4:insend_action'
actionpack (3.2.1) lib/abstract_controller/base.rb:167:in process_action' actionpack (3.2.1) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (3.2.1) lib/abstract_controller/callbacks.rb:18:in block in process_action' activesupport (3.2.1) lib/active_support/callbacks.rb:491:in_run__3639096229169453998__process_action__3069518532180131002__callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.1) lib/active_support/callbacks.rb:385:in_run_process_action_callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.1) lib/abstract_controller/callbacks.rb:17:inprocess_action'
actionpack (3.2.1) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:30:inblock in process_action'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in block in instrument' activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:29:inprocess_action'
actionpack (3.2.1) lib/action_controller/metal/params_wrapper.rb:205:in process_action' activerecord (3.2.1) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
actionpack (3.2.1) lib/abstract_controller/base.rb:121:in process' actionpack (3.2.1) lib/abstract_controller/rendering.rb:45:inprocess'
actionpack (3.2.1) lib/action_controller/metal.rb:203:in dispatch' actionpack (3.2.1) lib/action_controller/metal/rack_delegation.rb:14:indispatch'
actionpack (3.2.1) lib/action_controller/metal.rb:246:in block in action' actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:incall'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in dispatch' actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:30:incall'
journey (1.0.1) lib/journey/router.rb:68:in block in call' journey (1.0.1) lib/journey/router.rb:56:ineach'
journey (1.0.1) lib/journey/router.rb:56:in call' actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:589:incall'
hoptoad_notifier (2.4.11) lib/hoptoad_notifier/rack.rb:27:in call' actionpack (3.2.1) lib/action_dispatch/middleware/best_standards_support.rb:17:incall'
rack (1.4.1) lib/rack/etag.rb:23:in call' rack (1.4.1) lib/rack/conditionalget.rb:25:incall'
actionpack (3.2.1) lib/action_dispatch/middleware/head.rb:14:in call' actionpack (3.2.1) lib/action_dispatch/middleware/params_parser.rb:21:incall'
actionpack (3.2.1) lib/action_dispatch/middleware/flash.rb:242:in call' rack (1.4.1) lib/rack/session/abstract/id.rb:205:incontext'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in call' actionpack (3.2.1) lib/action_dispatch/middleware/cookies.rb:338:incall'
ckeditor (3.5.4) lib/ckeditor/middleware.rb:15:in call' activerecord (3.2.1) lib/active_record/query_cache.rb:64:incall'
activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in call' actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:28:inblock in call'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in _run__1932999954533059250__call__1309779107945614448__callbacks' activesupport (3.2.1) lib/active_support/callbacks.rb:405:in__run_callback'
activesupport (3.2.1) lib/active_support/callbacks.rb:385:in _run_call_callbacks' activesupport (3.2.1) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:65:incall'
actionpack (3.2.1) lib/action_dispatch/middleware/remote_ip.rb:31:in call' actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall'
actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in call' railties (3.2.1) lib/rails/rack/logger.rb:26:incall_app'
railties (3.2.1) lib/rails/rack/logger.rb:16:in call' actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:incall'
rack (1.4.1) lib/rack/methodoverride.rb:21:in call' rack (1.4.1) lib/rack/runtime.rb:17:incall'
activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.4.1) lib/rack/lock.rb:15:incall'
actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in call' hoptoad_notifier (2.4.11) lib/hoptoad_notifier/user_informer.rb:12:incall'
railties (3.2.1) lib/rails/engine.rb:479:in call' railties (3.2.1) lib/rails/application.rb:220:incall'
rack (1.4.1) lib/rack/content_length.rb:14:in call' railties (3.2.1) lib/rails/rack/log_tailer.rb:14:incall'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in service' /Users/rhulse/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice'
/Users/rhulse/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /Users/rhulse/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

Rendered /Users/rhulse/.rvm/gems/ruby-1.9.3-preview1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (4.1ms)
Rendered /Users/rhulse/.rvm/gems/ruby-1.9.3-preview1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
Rendered /Users/rhulse/.rvm/gems/ruby-1.9.3-preview1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (6.4ms)

rhulse commented Feb 23, 2012

And here is the code for the extenstion: https://gist.github.com/1030551

Owner

justinfrench commented Feb 23, 2012

I can't really see how this was working under 1.8.7 with Formtastic 2.0.2 — have you upgraded Formtastic from 1.x at the same time? Either way, here's the steps I'd take to narrow this down:

  1. Formtastic is expecting the custom input classes to be defined without a module, so that would be a first step.
  2. I typically place them in one file per input, e.g. app/inputs/wysiwyg_input.rb, app/datepicker_input.rb, etc
  3. You seem to have old style (e.g. def programme_select_input) and new style (e.g. class ProgrammeSelectInput) side-by-side. Delete the old style, keep the new. The old ones will not work with Formtastic 2.x.

Let me know how you go, closing for now.

rhulse commented Feb 23, 2012

This was a new(ish) app that has had formtastic added to it.

I removed the module wrapping the extensions and it now works.

Odd that it should work with the module in Ruby 1.8.7.

The old style was in there as I copied this code from another app and had not deleted it yet after the conversion.

Collaborator

mjonuschat commented Feb 24, 2012

That was due to 1.9.3 - if you wrap a class in a module the autoloader expects the directory structure to match. So Mymodule::CustomInput needs to be in app/inputs/mymodule/custom_input.rb

1.8.7 and 1.9.2 didn't care as much and happily loaded app/inputs/custom_input.rb

rhulse commented Feb 29, 2012

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment