Using data in application.rhtml layout

I’d say the nicest/cleanest thing to do would be to set that sidebar to be populated via AJAX. When the page loads, send of a request to the forum controller and update the sidebar div.

Jason

Well, here’s all the code you would need to get the AJAX working:

application.rhtml: …

<%= javascript_tag remote_function(:update => 'sidebar', :url => {:controller => 'forum_controller', :action => 'sidebar_action' }) %>

I’m assuming the action on the forum controller already exists, and you’d just need a partial that renders just those items.

However, if you really want a non-ajax format, I guess you would need a method on the Forum model (if you don’t already have that) and then in your application.rb you can have:

class Application … after_filter :fill_in_sidebar

def fill_in_sidebar @sidebar_posts = Forum.find_newest_posts end end

This will call #fill_in_sidebar after any action on any controller.

Hope that helps.

Jason