Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: protected method `render' called for ... #176

Open
haslinger opened this issue Jan 14, 2016 · 10 comments
Open

Error: protected method `render' called for ... #176

haslinger opened this issue Jan 14, 2016 · 10 comments

Comments

@haslinger
Copy link

I see one more regression (updating from Hobo 2.1.1. to 2.2.4 / Ruby 4.0.13 to 4.2.5):

Overriding an index method

def index
  # some ruby
  hobo_index
end

falls in several occasions with the error

  protected method `render' called for #<BlogpostsController:0x00000012e76370>
  app/controllers/blogposts_controller.rb:27:in `index'

Full sourcecode of the controller is available .

@enwood
Copy link

enwood commented Jan 14, 2016

Stefan, I'm not convinced this is Hobo.
See https://groups.google.com/forum/#!topic/hobousers/8j9kCBAaqI4

Tim

@haslinger
Copy link
Author

Maybe the full stracktrace is usefull:

Started POST "/__better_errors/fc5f31ef08eeeee8/variables" for 127.0.0.1 at 2016-01-14 15:29:00 +0100

Started GET "/podcasts" for 127.0.0.1 at 2016-01-14 15:29:55 +0100
Processing by PodcastsController#index as HTML
  User Load (0.1ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 144526 LIMIT 1
  Podcast Load (0.2ms)  SELECT  `podcasts`.* FROM `podcasts` WHERE `podcasts`.`published_at` IS NOT NULL  ORDER BY podcasts.published_at DESC, `podcasts`.`published_at` DESC LIMIT 1 OFFSET 0
   (0.1ms)  SELECT COUNT(*) FROM `podcasts` WHERE `podcasts`.`published_at` IS NOT NULL
Completed 500 Internal Server Error in 13ms (ActiveRecord: 0.1ms)

NoMethodError - protected method `render' called for #<PodcastsController:0x007f3a41f60ae0>:
  responders (2.1.1) lib/action_controller/responder.rb:236:in `default_render'
  responders (2.1.1) lib/action_controller/responder.rb:170:in `to_html'
  responders (2.1.1) lib/action_controller/responder.rb:163:in `respond'
  responders (2.1.1) lib/action_controller/responder.rb:156:in `call'
  responders (2.1.1) lib/action_controller/respond_with.rb:205:in `respond_with'
  hobo (2.2.4) lib/hobo/controller/model.rb:534:in `index_response'
  hobo (2.2.4) lib/hobo/controller/model.rb:486:in `hobo_index'
  app/controllers/podcasts_controller.rb:22:in `index'
  actionpack (4.2.5) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.5) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.5) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.2.5) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.2.5) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.5) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
  activesupport (4.2.5) lib/active_support/callbacks.rb:505:in `call'
  activesupport (4.2.5) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
  activesupport (4.2.5) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
  activesupport (4.2.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.5) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.2.5) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.2.5) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.5) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.2.5) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  searchkick (0.9.1) lib/searchkick/logging.rb:107:in `process_action'
  activerecord (4.2.5) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.2.5) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.5) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.2.5) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.2.5) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.2.5) lib/action_controller/metal.rb:237:in `block in action'
  actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
  actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:45:in `serve'
  actionpack (4.2.5) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.5) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:817:in `call'
   () home/stefan/.rvm/gems/ruby-2.1.5/bundler/gems/rails-dev-boost-a709a10b06b7/lib/rails_development_boost/async.rb:12:in `block in call'
   () home/stefan/.rvm/gems/ruby-2.1.5/bundler/gems/rails-dev-boost-a709a10b06b7/lib/rails_development_boost/async.rb:39:in `block in synchronize'
  /home/stefan/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
   () home/stefan/.rvm/gems/ruby-2.1.5/bundler/gems/rails-dev-boost-a709a10b06b7/lib/rails_development_boost/async.rb:39:in `synchronize'
   () home/stefan/.rvm/gems/ruby-2.1.5/bundler/gems/rails-dev-boost-a709a10b06b7/lib/rails_development_boost/async.rb:12:in `call'
   () home/stefan/.rvm/gems/ruby-2.1.5/bundler/gems/i18n-js-0de86694911b/lib/i18n/js/middleware.rb:11:in `call'
  rack (1.6.4) lib/rack/etag.rb:24:in `call'
  rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.4) lib/rack/head.rb:13:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.5) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.5) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
  activesupport (4.2.5) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
  activesupport (4.2.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.5) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.5) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.5) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.5) lib/rails/rack/logger.rb:20:in `call'
  ahoy_matey (1.2.1) lib/ahoy/engine.rb:18:in `call_with_quiet_ahoy'
  quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
  request_store (1.2.0) lib/request_store/middleware.rb:8:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.5) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/static.rb:116:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.5) lib/rails/engine.rb:518:in `call'
  railties (4.2.5) lib/rails/application.rb:165:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  /home/stefan/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
  /home/stefan/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
  /home/stefan/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

In case you're wondering: responders is seen here because:

/home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/action_controller/metal/mime_responds.rb:10:in `respond_to': The controller-level `respond_to' feature has been extracted to the `responders` gem. Add it to your Gemfile to continue using this feature: (NoMethodError)
  gem 'responders', '~> 2.0'

So maybe I should move away from controller level respond_with ...

@haslinger
Copy link
Author

@enwood Thanks for your comment, I believe it's an incompatibility to Rails 4.2.x ... will look into this as well ...

@enwood
Copy link

enwood commented Jan 14, 2016

Yes I thought the responders gem might be a culprit. Haven't confirmed
yet, but I was NOT using any respond_with calls in my controller methods
and had the error.

I've just had to back down to Rails 4.0.8, no responders gem, and Hobo
2.1.1 to be productive again.

T

On Thu, Jan 14, 2016 at 9:37 AM, Stefan Haslinger notifications@github.com
wrote:

@enwood https://github.com/enwood Thanks for your comment, I believe
it's an incompatibility to Rails 4.2.x ... will look into this as well ...


Reply to this email directly or view it on GitHub
#176 (comment).

@haslinger
Copy link
Author

Thanks again @enwood , I'm not in trouble here and can move backwards any time, so no worries :-).
I found out, it's also not me here using the respond_with, the trouble comes from Hobo itself in

gems/hobo-2.2.4/lib/hobo/controller/model.rb

Line 35.

@iox
Copy link
Member

iox commented Jan 20, 2016

Hi Stefan,

I have tried to reproduce this error in an empty app, unsuccessfully. Maybe there's some gem/ruby version incompatibility we are missing.

I have uploaded the test app here: test_rails_425.zip. I'm running it with Ruby 2.1.5p273, Rails 4.2.5, and Hobo 2.2.4.

Can you download it and try to see if the error happens? The "ThingsController" should have a similar code to your PodcastsController.

Warm regards,
Ignacio

@haslinger
Copy link
Author

Hi Ignacio,

thanks for your efforts, I can confirm, that your test app runs fine.

I will no go on and intruduce gems and later probably code to reproduce the issue.
So it's probably not an hobo issue at all...

Cheers, Stefan

@haslinger
Copy link
Author

OK, I drilled it down. Ignacio, please change the line in the Gemfile of your test app

gem 'responders', '~> 2.0'

to

gem 'responders', '2.1.1'

to see it fail, change it to

gem 'responders', '2.1.0'

to see it succeed again. To be precise, Hobo is compatible to responders in version 2.1.0, but not to 2.1.1 .

Cheers, Stefan

@iox
Copy link
Member

iox commented Jan 21, 2016

Thanks a lot Stefan, that makes a lot of sense. I'll try to find out what's wrong.

@enwood
Copy link

enwood commented Jan 21, 2016

I've seen a quick work-around ("band-aid") to be this in your controllers:

public :render

Tim

On Thu, Jan 21, 2016 at 4:34 PM, Ignacio Huerta notifications@github.com
wrote:

Thanks a lot Stefan, that makes a lot of sense. I'll try to find out
what's wrong.


Reply to this email directly or view it on GitHub
#176 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants