class User < ActiveRecord::Base
  belongs_to :school
  validates :email, :email => { :message => "Must be a valid email." }, :format => { :with => /\A[\w+\-.]+@#{Regexp.quote(school.email_domain)}\z/i }
end  
作成時にユーザーのメールが学校のメール ドメインと一致することを検証できるようにしたいと考えています。私は次の方法でユーザーを作成しています:
@school.users.create(params[:user])
スローされたエラー:
undefined local variable or method `school' for #<Class:0x007f8aaabb0df0>
助けてくれてありがとう!