Randomness for you since 1976
This may seem like, and probably is, so elementary that it isn’t worth writing about. I poked around on Google for a bit and couldn’t find the answer though, so it might be worth sharing. Basically I have a Ruby on Rails application with a controller whose corresponding views directory is getting hard to look at. For all my bazillions of partials I prefix them with something so they sort together _pet_detail_comments.rhtml, _pet_detail_properties.rhtml. You get the idea.
As I approach 30 views in one directory though, it starts to get hard to look at. I am an organization freak, so I want to group partials by context and put them in subdirectories:
/app/views/petstore/detail/ /app/views/petstore/checkout/ /app/views/petstore/article/ /app/views/petstore/forum/
When you render the partial you have to use the full path of: controller/subdirectory/partial_or_view. At first I wasn’t using the controller in the path, and you need it for this to work, apparently. So rendering a partial looks like this:
Rubyists always talk about clean, easy to read code. I have always thought that this sort of thing is just as important. Happy organizing.
This blog is a dumping grounds for my experiences as a web developer, a parent, an artist, a writer and a human being. Maybe someday there will be something here that is worth your time, some sort of useful information or words that piece your very soul. Probably not though.
Leave a reply