Closed swiknaba closed 4 years ago
I’ll look into this soon, sorry to hear about that. Once I can confirm, I’ll yank 0.14.1 until this is resolved
Thanks! I created a sample app to reproduce the issue: https://github.com/swiknaba/rabl_0140
Same problem here.
We're presenting an ActiveRecord::Relation
object in our templates:
# controller
@tags = Tag.where(...)
# template
object @tags
attributes :id, :name, :position
The workaround for this is converting the collection to an array (but that's obviously bad for performance):
object @tags.to_a
Yeah, I just bitten by this, locking the gem to 0.14.0 until either it's fixed or, presumably, I move to Rails > 4.2 and this is no longer an issue
Confirm this issue.
Problem is in commit: 4cf2c667a8f05eb5e04abf371c0978f6604574ab
exactly this change: https://github.com/nesquena/rabl/commit/4cf2c667a8f05eb5e04abf371c0978f6604574ab#diff-5a71730235e40573daff6c167a927d5dR85-R89
because on Rails 4 an active record relation responds to both :map
and :each
but it is not an enumerable
[2] pry(main)> Document.all.respond_to?(:map)
=> true
[3] pry(main)> Document.all.respond_to?(:each)
=> true
[4] pry(main)> Document.all.is_a?(Enumerable)
=> false
Hope it helps
Sorry to hear about this, I am unfortunately no longer able to actively maintain RABL (which I first created many years ago now) as you probably gathered, though I still happily use an old version on several of my own apps. It's honestly amazing to me that it's still used as much as it is!
If anyone can point me to a PR, and a recommended course of action, I'd be more than happy to push a 0.14.2 to resolve this
@tagliala Sent me a PR, I merged and released the fix as 0.14.3! I've also marked you as a contributor @tagliala if you can help keep RABL alive and well in whatever capacity you can, I appreciate it. That goes for anyone else reading this thread too.
Sorry that I haven't been able to maintain this much in the last few years, it is genuinely humbling that people still use this library, and sorry it isn't even better! I do still use this library myself extensively, I just have it locked to old versions of Sinatra and haven't needed any new features in a long time.
@nesquena apologies are not necessary. Thank you for all these years, I've been using rabl since forever 🙏🏼
Having the following setup in an older app running on
ruby 2.4.6
andrails 4.2.11.1
With Rabl
0.14.0
this renders properly:Upgrading to
0.14.1
it just renders nothing, no error raised:I am not very familiar with Rabl, to be honest, are the views here just basically wrong and working by chance in this setup, or did we find a breaking change that slipped in a minor version bump?