我的模态正在工作(意味着当我单击按钮时它会出现)但表单没有出现,我在索引操作中有这个模态所以我添加了<% @entries.each do |entry| %>
,没有它我是aving undefined method
NilClass:Class 的模型名称,有什么建议吗?
<%= link_to "Assign", "#saturday-one", :class => "btn btn-primary", "data-toggle" => "modal" %>
<div class="modal hide fade" id="saturday-one">
<div class="modal-header">
<h3 id="myModalLabel">Time Table</h3>
</div>
<div class="modal-body">
<% @entries.each do |entry| %>
<%= simple_form_for(entry) do |f| %>
<%= f.association :subject, as: :select, label: 'Select Subject' %>
<%= f.association :employee, as: :select, label: 'Assign Employee' %>
<%= f.submit %>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<button aria-hidden="true" class="btn btn-info" data-dismiss="modal">Done</button>
</div>
</div>
time_table_entries_controller.rb
class TimeTableEntriesController < ApplicationController
def index
@entries = TimeTableEntry.all
end
def show
@entry = TimeTableEntry.find(params[:id])
end
def new
@entry = TimeTableEntry.new
end
def create
@entry = TimeTableEntry.new(params[:time_table])
if @entry.save
redirect_to time_table_entries_url , notice: 'Time table Entries saved'
else
render :new
end
end
def edit
@entry = TimeTableEntry.find(params[:id])
end
def update
@entry = TimeTableEntry.find(params[:id])
if @entry.update_attributes(params[:time_table])
redirect_to time_table_entries_url, notice: 'TimeTableEntry Updated.'
else
render :edit
end
end
end