Template question (easy)

So I originally took up a project of making a simple blog for myself
and some friends to use to communicate with family while at college.
I’ve got most of it finished code wise, I am now in the process of
formatting the pages so it is all identical.

I am wondering, in my views folder, I have several .rhtml template
files, is there a way I can just define a single template file and a
load point in the code, and have all my other template files load in
that defined spot on the template file?

If not, is there another solution, or am I simply going to have to copy
and paste my code into all of my template files so they all load the
same page layout?

Thanks,

Justin

Would

<%= puts IO.read(‘file’) %>

work?

Wait…

you said views folder. … If your using Rails try partials.

I haven’t had much practice with partials yet. I assume from what I
saw, a partial just grabs the little tiny segment of code I have, and
puts it somewhere else. Not entirely sure how to implement that
accurately though.

Any tips or starting places to figure out how to learn it?

It sounds like what you’re looking for is layouts.

app/views/layouts/*.rhtml

I’m sure there’s plenty of information scattered around the web on
using layouts, but you could also check a rails book, like Agile Web
Development with Rails.

Hope that’s helpful.

-Payton

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