Created
January 7, 2009 06:18
-
-
Save bkudria/44196 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Prospects | |
- unless @prospects.empty? | |
%table | |
%tr | |
%th Organization | |
%th Location | |
%th Url | |
%th Org url | |
- for stage, prospects in @prospects_by_stage | |
%tr | |
%th= ProspectStage[stage].name | |
- for prospect in prospects | |
%tr | |
%td= prospect.organization | |
%td= h prospect.location | |
%td= auto_link prospect.url | |
%td= auto_link prospect.url | |
%td= link_to 'Show', prospect | |
%td= link_to 'Edit', edit_prospect_path(prospect) | |
%td= link_to 'Destroy', prospect, :confirm => 'Are you sure?', :method => :delete | |
- else | |
%p You haven't entered any prospects! | |
= link_to 'New prospect', new_prospect_path |
This file contains hidden or 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
def index | |
@prospects = Prospect.find_all_by_user_id current_user.id | |
@prospects_by_stage = partition_by_stage(@prospects) | |
respond_to do |format| | |
format.html # index.html.erb | |
format.xml { render :xml => @prospects } | |
end | |
end | |
def partition_by_stage(prospects) | |
returned_hash = {} | |
stages = prospects.collect {|prospect| prospect.stage} | |
stages.each do |stage| | |
returned_hash[stage] = prospects.select {|prospect| prospect.stage == stage} | |
end | |
returned_hash | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment