has_many:through

@team is (effectively) an array of Teams. It must be if you think about it as you you have asked to find all the teams. You might be better to call it @teams Then you can do things like @teams.each do |team| # some code using team.rushing_offenses end

Again team.rushing_offenses is an array

Colin

Thanks guys,

So after a 36 hours the lightbulb finally clicked in. I think the greatest issue I found throughout this particular issue wasn't that I didn't hear what some of you were saying to me, it's that I couldn't see what you were saying to me.

The end result code for finding everything from both associated tables was:

@rushing_offenses.each do |r|   r.rank   r.team.name # this is the piece I did not understand how to code   r.games   r.etc....   r.etc.... end

I didn't know how to tie in the two tables code wise when iterating through each row. A lot of what I read concentrated more on talking about how associations work but less on how to code a simple select all rows statement. As I said beforehand, I work better when I see code. I just happened to stumble upon this while doing my own tests.. and then I understood a bit more..

But, I still have an issue with my list method and using code between two tables..

For instance,

I have a named_scope for the date between compiles:

named_scope :compiled_this_week, lambda { { :conditions => ['compiled_on

? and compiled_on < ?', Time.now.beginning_of_week,

Time.now.end_of_week] } }

.. and a list function to paginate my code:

  def self.list(search, page, orderby, sortby, numteams)     orderby = "rank" if orderby == nil     orderall = (sortby != 'asc' && sortby != nil) ? "DESC" : "ASC"     compiled_this_week.paginate :conditions => ['name like ?', "%#{search}%"], :order => orderby + " #{orderall}", :per_page => numteams, :page => page   end

In my index view I'm making a search call to :name,

        <% form_tag rushing_offenses_path, :method => 'get' do %>           <p>             <%= hinted_text_field_tag :search, params[:search], "Enter Team" %>             <%= submit_tag "Team Search", :name => nil %>           </p>         <% end %>

But of course the :name is not going to work now. I still do not know how to change the pagination to work between two tables.

If I find this answer, my brain will not explode but I'll finally be able to take a shower and my fiance won't make me sleep on the couch tonight.. :slight_smile:

By the way, Marnen - loved your site and the fact that you are into SCA..

Colin, Fred, and Eric - all four of you have helped me through a bunch of things so far. I only hope that one day I'll be knowledable enough that I can start answering other peoples' questions..