I am unable to call the build method for a has_many :through relation:
class League < ActiveRecord::Base
has_many :league_admins
has_many :league_users, :through => :league_admins, :source => :user
end
class User < ActiveRecord::Base
has_many :league_admins
has_many :leagues, :through => :league_admins
end
Conotroller
def create
@league = current_user.leagues.build(params[:league])
if @league.save
…
end
end
Error
RuntimeError in Admin/leaguesController#create
[]
RAILS_ROOT: /Users/chris/Documents/Projects/Rails/myleague
Application Trace | Framework Trace | Full Trace
app/controllers/admin/leagues_controller.rb:11:in `create’
Has something changed in Rails 2.1?