Hi Jeremy,
How can i filter Selection table based on entity's path field?
selection = Selection[5]
# I get selection id "5" from db.
selection*.path* is varchar and "*Test*"
I want to find all Selections that start with "Test%". Simply all relateds
selections. So here is simple model:
selecteds = Selection.where(Sequel.ilike(:path, "#{selection.path}%")).all
Which works. But how can i make this in model?
Something like:
class Selection < Sequel::Model
one_to_many :relateds, dataset: (lambda do |r|
r.where(Sequel.ilike(:path, "#{path}%"))
end)
end
Selection[5].relateds # <- here will list all selections that related to
this.
But it didn't worked.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/e2992c5f-6060-48cb-9b41-54dde930a588n%40googlegroups.com.