[From the issue I opened about it:
https://github.com/rails/rails/issues/28152]
I don't know if this is more a bug report or a feature request, or even an
SO question [image: :flushed:] anyway:
I have a model Activity which has a lot of sti types, so a lot of related
class files. I would like
I believe everything under app/models is loaded by default, so you
shouldn't need to add a subdirectory.
Allen Madsen
http://www.allenmadsen.com
On Fri, Feb 24, 2017 at 10:49 AM, Maurizio De Santis <
desantis.mauri...@gmail.com> wrote:
> [From the issue I opened about it: https://github.com/rail
I think this question might be better for Rails-talk or Stack Overflow, as
Rails-core is designated for discussion of the core itself.
However, I will answer it anyway
Unless I'm mistaken, OP is wanting to segregate his models into subfolders.
"The Rails way" philosophy on this, which I wi
>
> I think this question might be better for Rails-talk or Stack Overflow, as
> Rails-core is designated for discussion of the core itself.
>
Uh, sorry!
So you say I could do for example something like:
# app/models/activity.rb
class Activity < ApplicationRecord
end
# app/models/activity/activ
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
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 :
>
> not a Class within a Class, a Class within a Module, like so:
>
> module Activity
> class Activity1 < ActivityBase
> end
> end
>
> or, alterna
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 fastes
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/activ
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 Maur