Error when searching with news engine #16

Closed
nicinabox opened this Issue Mar 12, 2012 · 15 comments

Comments

Projects
None yet
6 participants

NoMethodError:

undefined method `item_url' for #<ActionDispatch...> 

In search/show.html.erb on this line:

 <%= link_to raw(result.title.gsub(/(#{Regexp.escape(params[:query])})/i, '<mark>\1</mark>')), result_url(result) %>
Stack trace:

actionpack (3.2.2) lib/action_dispatch/routing/routes_proxy.rb:34:in `method_missing'
actionpack (3.2.2) lib/action_dispatch/routing/polymorphic_routes.rb:127:in `polymorphic_url'
actionpack (3.2.2) lib/action_dispatch/routing/url_for.rb:150:in `url_for'
vendor/extensions/search/app/helpers/refinery/search_helper.rb:7:in `result_url'
vendor/extensions/search/app/views/refinery/search/show.html.erb:12:in `block in _vendor_extensions_search_app_views_refinery_search_show_html_erb__141027100073112144_2203181120'
vendor/extensions/search/app/views/refinery/search/show.html.erb:7:in `each'
vendor/extensions/search/app/views/refinery/search/show.html.erb:7:in `_vendor_extensions_search_app_views_refinery_search_show_html_erb__141027100073112144_2203181120'
actionpack (3.2.2) lib/action_view/template.rb:143:in `block in render'
activesupport (3.2.2) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.2) lib/action_view/template.rb:141:in `render'
actionpack (3.2.2) lib/action_view/renderer/template_renderer.rb:42:in `block (2 levels) in render_template'
actionpack (3.2.2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.2) lib/action_view/renderer/template_renderer.rb:41:in `block in render_template'
actionpack (3.2.2) lib/action_view/renderer/template_renderer.rb:49:in `render_with_layout'
actionpack (3.2.2) lib/action_view/renderer/template_renderer.rb:40:in `render_template'
actionpack (3.2.2) lib/action_view/renderer/template_renderer.rb:13:in `render'
actionpack (3.2.2) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.2) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:109:in `_render_template'
actionpack (3.2.2) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.2) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.2) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.2) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/Nic/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
activesupport (3.2.2) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.2) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:39:in `render'
refinerycms-pages (2.0.1) lib/refinery/pages/instance_methods.rb:27:in `render'
actionpack (3.2.2) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.2) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.2) lib/active_support/callbacks.rb:447:in `_run__2503327464324143695__process_action__3473978403548058199__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.2) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
airbrake (3.0.9) lib/airbrake/rack.rb:27:in `call'
lib/canonical_redirect.rb:11:in `call'
warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
warden (1.1.1) lib/warden/manager.rb:34:in `catch'
warden (1.1.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/cookies.rb:338:in `call'
dragonfly (0.9.10) lib/dragonfly/cookie_monster.rb:9:in `call'
activerecord (3.2.2) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `_run__1720640446410079874__call__3076861498807562369__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
dragonfly (0.9.10) lib/dragonfly/middleware.rb:13:in `call'
dragonfly (0.9.10) lib/dragonfly/middleware.rb:13:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
airbrake (3.0.9) lib/airbrake/user_informer.rb:12:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/Nic/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/Nic/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/Nic/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Owner

ugisozols commented Mar 13, 2012

Confirmed.

Note to self - issue is related to namespaced models. In this case it should return news_item_url but it returns item_url instead.

Owner

parndt commented Mar 19, 2012

Have to use refinery. prefix on routes

Owner

parndt commented Mar 19, 2012

Just realised that result_url does that. ;-)

Owner

parndt commented Apr 6, 2012

@ugisozols can we use ActiveModel::Naming.param_key at all here?

Owner

ugisozols commented Apr 6, 2012

No because ActiveModel::Naming.param_key(Refinery::News::Item) will return item but we need news_item...

Owner

parndt commented Apr 6, 2012

route_for_model ?

ugisozols was assigned Apr 6, 2012

dekom commented Apr 11, 2012

Any new updates on the issue?

Owner

parndt commented Apr 11, 2012

Nope, not from me :(

Owner

ugisozols commented Apr 11, 2012

None here either... for now.

Any one working on this? We are running in this same issue, also with some custom engines...

Owner

ugisozols commented May 8, 2012

Not me ...

Never mind, we overwrite the url method of our model to get it working. Seems a bit hacky, but is works ;-)

Owner

parndt commented May 14, 2012

This is an intended behaviour of Rails' ActiveModel::Naming https://github.com/rails/rails/blob/master/activemodel/lib/active_model/naming.rb#L123-L133 because it's an isolated engine.

Not sure how we get around this other than the hacky approach of providing a url method on Refinery::News::Item.

Owner

parndt commented May 14, 2012

I have a great idea coming up! It requires Refinery 2.0.4 though.

@parndt parndt referenced this issue in refinery/refinerycms May 14, 2012

@parndt parndt Fixes resolve/refinerycms-search#16
This works by allowing refinery.url_for(Refinery.route_for_model(result.class, :admin => false)) to be used in place of refinery.url_for(result)
59970c6

parndt closed this in 004f63b May 14, 2012

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