class AddDataToStudentForCourse < ActiveRecord::Migration
  def change
    Course.all.each do |course|

      course.members.each do |m|
        if m && m.user && m.user.allowed_to?(:student,course) && StudentsForCourse.find_by_student_id(m.user).nil?
          StudentsForCourse.create(:student_id => m.user_id, :course_id => course.id)
        end
      end

    end
  end
end
