3
나는 이벤트와 사용자/팀을 보유하고 있습니다. 나는 사용자를 등록 할 때테이블 및 레일 조인
class Event
has_many :users, :through => :registrations
end
class User
has_many :events, :through => :registrations
end
class Registration
belongs_to :users
belongs_to :events
end
, 정말 같은 이벤트를 연결 해요 :
@event.users << @user
이 암시 적으로 사용자/이벤트에 대한 등록 객체를 생성합니까? 내 등록 마이그레이션에 goal_amount 열을 넣었습니다. 등록을 만들 때 : goal_amount를 설정할 수 있기를 원합니다. (즉, 내가 명시 적으로 등록을 작성해야합니까?. Registration.create(:user_id => @user.id, :event_id => @event.id, :goal_amount => params[:goal_amount])
이런 일이
고마워요! 그게 완벽하게 작동했습니다 :) –
다음 내 대답을 받아 들인대로 표시;) –