我有 3 个模型:客户、员工、票证。我想在创建新工单时使用下拉列表选择employee_id,但它给了我这个错误
undefined local variable or method `employee' for #<#<Class:0x3f2c880>:0x3f4a070>
Extracted source (around line #16):
13:
14: <div class="field">
15: <%= f.label :employee_id %><br />
16: <%= f.select :employee_id, employee.all.map{|s| [s.name, s.id]} %>
17: </div>
18: <div class="field">
19: <%= f.label :customer_id %><br />
据我了解,这一定是因为我没有将员工设置为全局变量。我在控制器中看到了这条线:
def new
@employee = Employee.new
我该如何解决?