ranked-model
ranked-model copied to clipboard
allow writing with_same in string
now we can do:
ranks :row_order,
with_same: 'service_id IN (SELECT id FROM services WHERE agency_id = #{instance.agency_id})'
has_one :agency, through: :service
delegate :id, :name, to: :agency, prefix: true
fix issue #89
this would be great to allow ranking through associations!
Perhaps there's a cleaner way to do this?
Sorry, by cleaner, I mean safer.
Yep, I was thinking the same - then again, I don't know how user input should make it into a class method 😬 , but you never know.
Totally spitballing, but what if instead of eval
ing a string, you could pass a lambda to with_same
? That would (probably?) allow joining your association together until you arrive at the necessary key?
I will let anyone of you takeover of this pull request. I don't have time anymore to handle it and I don't use this gem anymore neither.
All good @gagalago.
Yes @julianrubisch, perhaps something like a proc or lambda that exposes the current scope as self
so that it can be further refined?