Re: [Rails-core] Organize models in subfolders

2017-03-01 Thread Tom Prats
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

Re: [Rails-core] Organize models in subfolders

2017-03-01 Thread Maurizio De Santis
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 #

Re: [Rails-core] Organize models in subfolders

2017-02-27 Thread Jason Fleetwood-Boldt
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

Re: [Rails-core] Organize models in subfolders

2017-02-27 Thread Maurizio De Santis
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 >

Re: [Rails-core] Organize models in subfolders

2017-02-24 Thread Jason Fleetwood-Boldt
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

Re: [Rails-core] Organize models in subfolders

2017-02-24 Thread Maurizio De Santis
> > 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 #

Re: [Rails-core] Organize models in subfolders

2017-02-24 Thread Jason Fleetwood-Boldt
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

Re: [Rails-core] Organize models in subfolders

2017-02-24 Thread Allen Madsen
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:

[Rails-core] Organize models in subfolders

2017-02-24 Thread Maurizio De Santis
[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