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 <t...@datatravels.com>:

>
> 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 <
> desantis.mauri...@gmail.com> 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 <t...@datatravels.com>:
>
>>
>> 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 <
>> desantis.mauri...@gmail.com> wrote:
>>
>> # app/models/activity/activity_1.rb
>> class Activity
>>   class Activity1 < Activity
>>   end
>> end
>>
>>
>> ----
>>
>> Jason Fleetwood-Boldt
>> t...@datatravels.com
>> 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/to
>> pic/rubyonrails-core/krboJIieoXk/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> rubyonrails-core+unsubscr...@googlegroups.com.
>> To post to this group, send email to rubyonrails-core@googlegroups.com.
>> 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 rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>
>
> ----
>
> Jason Fleetwood-Boldt
> t...@datatravels.com
> 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
> rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> 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 rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to