I’m curious as to how people organise their shared partials in this specific case. In my application, an index of listings can be displayed at either /listings or /users/:id/listings urls. Essentially either seeing all listings or my listings.
Both of the associated views /app/views/listings/index.html.haml and /app/views/users/listing/index.html.haml currently share a partial that does the bulk of the rendering. Really everything but the title, heading, a back link, and some text if there are no listings.
Where would you locate this partial. I’m torn between keeping it close to the main listing resource and also noting that it is shared a bit more widely…
If it’s a partial that specifically lists
listings, then I would vote for putting it inapp/views/listings/. If it handles a more complex or nuanced collection of data, then it should go in a common folder (I’ve seen it calledshared/,common/, orwidgets/, but that’s just a matter of preference).I think the key is about whether it can be classified as something to handle the display of a specific object or if it’s just some arbitrary block of view code that gets repeated throughout the app.