Skip to content

Instantly share code, notes, and snippets.

@kevinrutherford
Created February 1, 2012 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinrutherford/1718528 to your computer and use it in GitHub Desktop.
Save kevinrutherford/1718528 to your computer and use it in GitHub Desktop.
class MyController < ApplicationController
def show
@sysinfo = SysInfo.new(model_stuff, ...)
end
end
%h1 A page of stuff
%h2 A list of members
= @sysinfo.render_members_on(self)
%h2 A list of events
= @sysinfo.render_events_on(self)
class SysInfo
def initialize(model_stuff, ...)
# find things and calculate stuff
end
def render_members_on(template)
return '' unless @members.length > 0
template.render(:partial => 'path/to/members_partial', :locals => {@stuff})
end
def render_events_on(template)
@events.each do |event|
template.render(:partial => 'event/details', :locals => {...})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment