It's in HAML, which I hope is readable by most people here.. It's
concise though, which is nice.

So here's what I have in my beautiful first partial. Explanation of this
obviously poor code and logic is after the code.

#cr
  = render :partial => 'reports/lists', :locals => {:type => :cr,
:reports => reports.find_all { |i| i.modality == "CR" } }

#non_cr
  = render :partial => 'reports/lists', :locals => {:type => :non_cr,
:reports => reports.find_all { |i| !['MG', 'CR'].include? i.modality } }

#mammo
  = render :partial => 'reports/lists', :locals => {:type => :mg,
:reports => reports.find_all { |i| i.modality == "MG" } }

____________
____________
And here is the beautiful second partial : 'reports/lists'

%style
  .hideextra { white-space: nowrap; overflow: hidden; }


%center
  %h2
    - if type == :cr
      X-RAYS:
    - elsif type == :mg
      MAMMOGRAMS:
    - else
      MODALITIES OTHER THAN MAMMO AND XRAY:
    = reports.size

%table
  %thead
  %tr
    %th Name
    %th Date
    %th Age
    %th Procedure
  %tbody
    - reports.each do |report|
      %tr{ :class => cycle("even", "odd") }
        %td
          %div{ :style=>"width:215px"}= "#{report.last},
#{report.first}"
        %td
          %div{ :style=>"width:80px"}= report.date
        - if !report.old?
          %td
            %div{ :style=>"width:55px"}= report.age
        - else
          %td
            %b
              %div{:style=>"width:55px"}= report.age
        %td= report.proc

__________
__________
The first partial is called by the controller action, and in turn, it
splits the data a little more. There's clearly some logic in there which
needs to be whisked away to some other location.
I am wondering if I should store the split into a hash, in a kind of
'settings' table, and then recall that.
Can I loop over a partial and call it over and over, with slightly
varying data sent to it (like the symbol, in here).. And if so, how do I
handle the fact that I want to display slightly different data in each
partial depending on what I'm displaying?

I am open to complete renovation, all the way straight down to the
fundamentals, so if I need to break the logic down completely and
rebuild it, I'm cool with that. I just know my way of thinking does not
scale, and I'm wondering how seasoned pros would do it.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to