Skip to content

Instantly share code, notes, and snippets.

@basicxman
Created June 17, 2011 16:30
Show Gist options
  • Select an option

  • Save basicxman/1031752 to your computer and use it in GitHub Desktop.

Select an option

Save basicxman/1031752 to your computer and use it in GitHub Desktop.
# ApplicationController
def render_sidebar_widget(path, item = nil)
locals = {}
locals = self.send(item) unless item.nil?
render_to_string(:partial => path, :locals => locals).html_safe
end
helper_method :render_sidebar_widget
def reading_list
set(:reading_items, ReadingItem.updated_desc.all)
{ :reading_items => @reading_items }
end
# View
<% render_sidebar_widget("reading_items/listing", :reading_list) %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment