Created
February 1, 2012 18:35
-
-
Save kevinrutherford/1718528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyController < ApplicationController | |
def show | |
@sysinfo = SysInfo.new(model_stuff, ...) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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