Chris Olsen wrote:
What is current_user.leagues?
I suspect that account.listings is an active record association, as in
class Account < ActiveRecord::Base
but current_user.leagues is some kind of Ruby collection, like an array.
A has_many association masquerades as a Ruby array for most uses, but it
changes the find method (which Array gets from the Enumerable module) to
a sequel query instead of yielding to a block.
This is what I have:
class User < ActiveRecord::Base
has_many :leagues, :through => :league_admins
class League < ActiveRecord::Base
has_many :users, :through => :league_admins
class LeagueAdmin < ActiveRecord::Base
I guess someone spiked my coffee :). I have probably just never tried
to perform a find in the way I am now. Usually when I have a relation
like this the most I would do is view the related items, but I guess
the has_many :through only party behaves like a normal has_many.
Is there a rails way to make an association between these two classes,
since that is something else that no longer exists, or does a person
just do it manually?
@league = League.new(params[:league])
@league_admin = LeagueAdmin.new(:league_id => @league.id, :user_id