ccocchi / rabl-rails

Rails 4.2+ templating system with JSON, XML and Plist support.
MIT License
209 stars 51 forks source link

`rendered_format` is removed in Rails 6.1 #93

Closed nicksoto closed 3 years ago

nicksoto commented 4 years ago

the relevant commit is here

javierjulio commented 4 years ago

Based on that commit and seeing other repos that have updated to account for the deprecation warning, I think we just need to change this line: https://github.com/ccocchi/rabl-rails/blob/4d3ec11096a840d2d1cd43c7a59d92294d0b8323/lib/rabl-rails/library.rb#L28 to do the following instead:

format = view.lookup_context.formats.first || :json

Note: I'm not sure if that change would work on older Rails versions though.

I think this change in that same commit Nick shared backs the above suggestion since the rendered_format was set with the same value.

javierjulio commented 4 years ago

The rspec-rails gem has addressed the same issue here: https://github.com/rspec/rspec-rails/pull/2100 so that should confirm the solution and that the change has to be conditional for Rails 6 and then anything else for older versions.

navidemad commented 4 years ago

Something like this :

format = (::Rails::VERSION::STRING >= '6' ? view.lookup_context.formats.first : view.lookup_context.rendered_format) || :json
ccocchi commented 3 years ago

Thank you, the warning have been removed in version 0.6.0 🙂