Closed mahemoff closed 6 years ago
Among other problems, your question says app/blogs
but your code snippet says app/models
.
The config is app/models
because I'm trying to make it generic, since all models follow this convention, but not sure how to do it. (Updated the above from app/blog
as you're right it should be app/models/blog
).
The question is if there's a way to override the generic Rails convention of models all being in the same app/models folder, e.g. for a project using /app/models/blogs/blog.rb, app/models/posts/post.rb and so on, without having to configure a rule for each specific model type.
I don't understand the question. You can access a file at app/models/blog/blog.rb
with :Emodel blog/blog
. Are you trying to avoid typing blog
twice? Because I don't think there is a way to achieve that, no.
Less typing would be nice but more importantly, navigation - so I could hit gf
on Blog for example. Doing so causes the cannot find
error.
You can fix gf
by adjusting 'path'
to include .../app/models/*
. From memory, I think this would work:
{
"*.rb": {"path": "app/models/*"}
}
Rails officially supported this convention a decade or so ago, but dropped it because it was way more trouble than it was worth. I'd encourage you to rethink as well.
Is there a way to handle projects using the convention
/app/models/blogs/blog.rb
for models?I've tried this for config/projections.json, but it still gives
cannot find file "blog.rb" in path
.