I'd still be interested in how to make this possible without name-spacing the models. With STI the type column is more presentable to an end user without it. Activity::Something vs. Something. It'd be nice if this were possible (if not the default).
Thanks, Tom On Wed, Mar 1, 2017 at 1:25 PM Maurizio De Santis < [email protected]> wrote: > It works!!! In many years I've been working with Rails I wasn't aware > about this way to organize models. Thank you! > > For the namespace instead of defining an Activity module I just used the > model Activity: > > # app/models/activity.rb > class Activity < ApplicationRecord > end > > # app/models/activity/activity_1.rb > class Activity::Activity1 < Activity > end > > And it works like a charm! Thank you! > > > -- > > Maurizio De Santis > > 2017-02-27 23:04 GMT+01:00 Jason Fleetwood-Boldt <[email protected]>: > > > Yes, as I had explained in my previous email, you will absolutely need to > rename the objects in the 'type' column when using STI/polymorphism. There > are several other things to consider as well when making this kind of an > object name change. > > You can do this directly in SQL (it would be fastest, and works around the > impossibility of loading these records). I would suggest doing it in SQL in > a migration. > > -Jason > > > On Feb 27, 2017, at 12:38 PM, Maurizio De Santis < > [email protected]> wrote: > > This seems to break the STI :-( Activity1 is not found as an STI class > > > -- > > Maurizio De Santis > > 2017-02-24 19:08 GMT+01:00 Jason Fleetwood-Boldt <[email protected]>: > > > not a Class within a Class, a Class within a Module, like so: > > module Activity > class Activity1 < ActivityBase > end > end > > or, alternatively... > > class Activity::Activity1 < ActivityBase > > > Note in my example I renamed your base class to "ActivityBase" because I > believe if you continue to reference it as simply "Activity" you'll run > into namespace problems. > > -Jason > > > On Feb 24, 2017, at 12:46 PM, Maurizio De Santis < > [email protected]> wrote: > > # app/models/activity/activity_1.rb > class Activity > class Activity1 < Activity > end > end > > > ---- > > Jason Fleetwood-Boldt > [email protected] > http://www.jasonfleetwoodboldt.com/writing > > If you'd like to reply by encrypted email you can find my public key on > jasonfleetwoodboldt.com (more about setting GPG: https://gpgtools.org) > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ruby on Rails: Core" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/rubyonrails-core/krboJIieoXk/unsubscribe > . > To unsubscribe from this group and all its topics, 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/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" 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/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > > > ---- > > Jason Fleetwood-Boldt > [email protected] > http://www.jasonfleetwoodboldt.com/writing > > If you'd like to reply by encrypted email you can find my public key on > jasonfleetwoodboldt.com (more about setting GPG: https://gpgtools.org) > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ruby on Rails: Core" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/rubyonrails-core/krboJIieoXk/unsubscribe > . > To unsubscribe from this group and all its topics, 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/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" 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/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" 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/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
