-
azul authored
We used to have app/models/activity in the autoload path and had classes like FriendActivity < Activity This conflicts with how rails4 handles class lookup. Plus it clutters the autoload path and makes it harder to find classes. Using proper namespaces instead now and I'm about to apply this to all the different namespace avoiding things like ...Extension. We can use classes as namespaces as long as we: * make sure to define things inside the namespace in one line or in a class instead of a module block: ```ruby class Activity::Friend < Activity # or class Activity class Friend < ::Activity ``` * have names inside the namespaces that do not conflict with global names The second one is important because if PrivatePost is already loaded and Activity::PrivatePost is referenced somewhere it will be found as an constant inside the Object namespace of Activity (since Activity is a class). So instead of loading Activity::PrivatePost we'll see a warning that global constant PrivatePost was referenced by Activity::PrivatePost. So how do we prevent this? * do not clutter the global namespace * use more specific names in other namespaces -> in this case i am renaming PrivatePostActivity to Activity::MessageSent and not Activity::PrivatePost