On Monday, September 24, 2018 at 3:28:37 AM UTC-7, Janko Marohnić wrote:
>
> Hello,
>
> In our application we have Sequel models namespaced under 
> `MyApp::Models::*`. Currently when declaring associations where class name 
> cannot be inferred, we always have to specify the full class name, e.g.
>
>   class MyApp::Models::Article < Sequel::Model
>     many_to_one :created_by, class: "MyApp::Models::User"
>   end
>
> I know it's also possible to use a Symbol instead of a String, which 
> currently has the same behaviour. I was thinking that it would be 
> convenient that when specifying :class as a Symbol, Sequel searches the 
> current namespace, so that you could do:
>
>   many_to_one :created_by, class: :User
>   # resolves to MyApp::Models::User
>
> One problem is that this would be a backwards incompatible change.
>
> Alternatively I found out about the :class_namespace association option, 
> which is definitely convenient. Is there any way to specify it as default 
> for all associations?
>

  Sequel::Model.default_association_options = 
{:class_namespace=>'MyApp::Models'}

Thanks,
Jeremy

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to