Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Christopher Quinn
Christopher Quinn
9,943 Points

Populating a column with links in Rails

I'm trying to build a blog app for my wife and I'm trying to figure out how to proceed with this next part.

<h3>Blog Posts</h3>
<% @blogposts.each do |blogpost| %>
    <a href="./blogposts/<%= blogpost.id %>">
        <%= blogpost.title %>
    <br />
<% end %>

Currently I am using this to populate a column with links of blog post titles that direct to a new page (just to test functionality) with the post contents. There are two columns on the page, the left side has the links, and the right side is blank and I would like to be able to click a link and render a partial page in that right side column. I'm not looking for someone to write the code for me, but I am asking for a little direction.

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

If you want this to be done without refreshing the whole page, you'd need to use jQuery (or pure JavaScript). I you're OK with whole page refreshing, the right side column will have to render a single @blogpost based on the :id parameter in the URL.

Christopher Quinn
Christopher Quinn
9,943 Points

I would prefer to dynamically update it. I guess jQuery it is. Thank you.