Storing views in subdirectories?

I’d like to organize my project structure by storing certain related
views into a subdirectory. For example, I have a bunch of interviews
which each contain their own view (the client doesn’t want them
content managed, or put in the database). Right now I have them
placed inside “app/views/site/interview_one.rhtml”,
“app/views/site/interview_two.rhtml”, etc. I’d like to place these
inside “app/views/site/interviews/interview_one.rhtml”… I’ve tried a
couple different methods, but I just can’t figure out how to get these
files into a subdirectory… If anyone has any hints, please let me
know. Thanks,



You could store them as partial views, such as
app/views/site/_interview_one.rhtml, and then render them from a
common view with:
render_partial “site/interview_one”

You could then keep common content in your view, and unique content in
your partial views. The partial view that you display could be
determined by the parameters passed into your view’s controller, as
specified in routes.rb.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs