Replies: 3 comments 5 replies
-
By default, for normal association loading, Sequel calls methods on the receiver to get the values used in the association query. If you want a static string literal, you could try defining a method that returns it. I'll admit I'm not sure what value there would be in having an association defined that way, unless you were using some other approach to make the association receiver-specific. Maybe it would help to provide a more complete example showing what you want? |
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick and valuable response as always @jeremyevans
That sounds reasonable! But would that work for dataset things, like I'll post a more complete example in a moment |
Beta Was this translation helpful? Give feedback.
-
Simplified the schemas and naming for the example, but it's something like this:
We want YoutubeAccount many_to_one Network on a constant value "youtube", which is the value of |
Beta Was this translation helpful? Give feedback.
-
Setting aside db schema design concerns... is it possible to define a model association where the FK value is a string literal defined in Ruby at definition time?
I tried this but i think it is trying to call a method by name of the value provided of slug:
base.many_to_one :network, key: Sequel.lit(base.slug), primary_key: :slug
e.g.
slug = "youtube"
Beta Was this translation helpful? Give feedback.
All reactions