I've got a create action that is attempting to create a Rating and a Programme in one go:
def create
@rating = current_user.ratings.create(params[:rating])
@rating.create_programme(params[:programme])
redirect_to ratings_path
end
In this code, a rating belongs to both a user and a programme and a user
has_many :ratings
has_many :programmes, :through => :ratings
and a programme
has_many :users, :through => :ratings
has_many :ratings
When I call the create action above in the RatingsController, the Programme is not being saved as being owned by the @rating for some reason. So if I call for instance:
rating.programme.channel
on a rating in a view, it tells me that the programme is a nil object. However, the programme has been saved fine - it's just the association that hasn't been saved. I'm sure it's a pretty basic thing here, but I can't figure it out. Can someone point me in the right direction?
thanks, a