Back to Blog

Rails 5 ensures compatibility with Rack frameworks

on June 30, 2016
This blog is part of our Rails 5 series.

Before Rails 5, there were errors in running integration tests when a Rack framework like Sinatra, Grape etc. were mounted within Rails with a motive of using its session.

Problems were reported at many places including github gists and stackoverflow regarding an error which was of the following form.

1
2NoMethodError (undefined method `each' for #<ActionDispatch::Request::Session:0x7fb8dbe7f838 not yet loaded>): rack (1.5.2) lib/rack/session/abstract/id.rb:158:in `stringify_keys'
3rack (1.5.2) lib/rack/session/abstract/id.rb:95:in `update' rack (1.5.2) lib/rack/session/abstract/id.rb:258:in `prepare_session'
4rack (1.5.2) lib/rack/session/abstract/id.rb:224:in `context' rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
5

As we can see, the error occurs due to absence of method each on an ActionDispatch::Request::Session object.

In Rails 5, each method was introduced to ActionDispatch::Request::Session class making it compatible with Rack frameworks mounted in Rails and hence avoiding the above mentioned errors in integration testing.


You might also like

If you liked this blog post, check out similar ones from BigBinary