mileszs / wicked_pdf

PDF generator (from HTML) plugin for Ruby on Rails
http://www.mileszs.com/wicked-pdf-plugin
MIT License
3.53k stars 645 forks source link

Runtime Error Can't modify frozen hash #489

Open nynhex opened 8 years ago

nynhex commented 8 years ago

I am using wicked_pdf 1.0.4 with wkhtmltopdf 0.12.2.1 in Rails 4.1.1/Ruby 2.1.

I have a simple view that is just HTML and says the word "test".

When I visit the URL https://localhost:3000/people/:id/poster/:id.pdf

I will error out and get the following error. can't modify frozen Hash in development. Same thing in production.

Here is what my code looks like.

poster.html.erb

<center>
  Testing
</center>

Here's what my controller method looks like

  def poster
    @name = Person.includes(:notes, :images, :relationships).find(params[:id])
  end

Here is the link code I use to generate the PDF view

  <%= link_to "Poster", poster_path(@name.id, format: 'pdf'), class: 'btn btn-small' %>

This happens consistently in development, and it's sporadic in production. Anyone ever seen this sort of issue? I don't see how it's generating or trying to modify a hash since the view is literally just html and no Ruby.

Any thoughts?

beechnut commented 8 years ago

@shakycode Would you post the stacktrace (perhaps in a gist)? I'm about to use this gem with a similar stack, and if I run into the same issue, we can compare notes.

nynhex commented 8 years ago

@beechnut Here's the stacktrace I see in the development log. I'm thinking this has to do with caching/cookies more than wicked_pdf. But I'm not sure.

Completed 200 OK in 82ms (Views: 20.7ms | ActiveRecord: 31.0ms)

RuntimeError - can't modify frozen Hash:
  actionpack (4.1.0) lib/action_dispatch/middleware/cookies.rb:307:in `[]='
  actionpack (4.1.0) lib/action_dispatch/middleware/cookies.rb:472:in `[]='
  actionpack (4.1.0) lib/action_dispatch/middleware/session/cookie_store.rb:110:in `set_cookie'
  rack (1.5.5) lib/rack/session/abstract/id.rb:350:in `commit_session'
  rack (1.5.5) lib/rack/session/abstract/id.rb:226:in `context'
  rack (1.5.5) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.1.0) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.1.0) lib/active_support/callbacks.rb:82:in `run_callbacks'
  actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  rack-contrib (1.2.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16: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.1.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.0) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.0) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.0) lib/rails/rack/logger.rb:20:in `call'
  request_store (1.1.0) lib/request_store/middleware.rb:8:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.5) lib/rack/runtime.rb:17:in `call'
  activesupport (4.1.0) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/static.rb:64:in `call'
  rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
  railties (4.1.0) lib/rails/engine.rb:514:in `call'
  railties (4.1.0) lib/rails/application.rb:144:in `call'
  railties (4.1.0) lib/rails/railtie.rb:194:in `method_missing'
  lib/cache_settings.rb:9:in `call'
  rack (1.5.5) lib/rack/deflater.rb:25:in `call'
  rack (1.5.5) lib/rack/content_length.rb:14:in `call'
  puma (2.15.3) lib/puma/server.rb:541:in `handle_request'
  puma (2.15.3) lib/puma/server.rb:388:in `process_client'
  puma (2.15.3) lib/puma/server.rb:270:in `block in run'
  puma (2.15.3) lib/puma/thread_pool.rb:106:in `block in spawn_thread'