我正在尝试使用下拉菜单修改表单,该菜单中填充了来自名为teacher_occupations的表的值。
在整个过程中,我从另一个表单下拉菜单中获得灵感,使用区域做同样的事情。
以下是表单代码:
<div class="row">
<div class="col-md-12">
<div class="form-group">
<%= form.label :region_id, class: 'form-label form-label--required' %>
<%= form.collection_select :region_id, available_regions, :id, :name, { prompt: true }, class: 'form-control form-control--select dropdownSelect' %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<%= form.label :teacher_occupation_id, class: 'form-label form-label--required' %>
<%= form.collection_select :teacher_occupation_id, available_teacher_occupations, :id, :name, {prompt: true}, class: 'form-control form-control--select dropdownSelect' %>
</div>
</div>
</div>
但是当我运行网页时,我有一个未定义的方法`teacher_occupation_id'用于#错误。
我尝试使用 TeacherCoordinates.new.methods - Object.new.methods 输出视图的实例方法 我可以看到region_id,teacher_occupation,但没有teacher_occupation_id。
我错过了什么?
答案 0 :(得分:0)
你应该改变
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(FilePath);
using (HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse()) {
using (Stream stream = myResp.GetResponseStream()) {
HttpResponse resp = HttpContext.Current.Response;
resp.Clear();
resp.ContentType = "Application/msword";
resp.AddHeader("Content-Disposition", "attachment; filename=xyz.doc");
int count = 0;
do
{
byte[] buf = new byte[10240];
count = stream.Read(buf, 0, 10240);
resp.OutputStream.Write(buf, 0, count);
resp.Flush();
} while (stream.CanRead && count > 0);
}
}
到
<%= form.label :teacher_occupation_id, class: 'form-label form-label--required' %>
<%= form.collection_select :teacher_occupation_id, available_teacher_occupations, :id, :name, {prompt: true}, class: 'form-control form-control--select dropdownSelect' %>