好的,所以我有一个应该返回包(service_package_id 和 payment_plan_id)的方法被传入并且有效。包模型属于服务包和付款计划,每个模型都有许多包。
@service_package = ServicePackage.find(service_package_id)
@payment_plan = PaymentPlan.find(payment_plan_id)
@package = @service_package.packages.build(:payment_plan_id => @payment_plan, :promo_code => "149", :price => "7.99", :number_of_free_days => "30", :setup_fee => "0", :initial_price => "0.00", :initial_price_duration => "30", :final_price => "0")
logger.error "package #{@package.service_package_id}"
@spackage = @package.service_package
logger.error "spackage #{@spackage.description}"
在@spackage 行之前,一切都很好。记录器获取 service_package_id 但是当下一个日志出现时,它会在 nil 类上返回 nomethoderror。为什么我的@spackage 为零?这适用于rails 3.0.9,但至少在我的开发机器上不适用于3.1 rc4。有什么想法吗?