構建基本表單以創建新數據時收到以下錯誤。當我點擊提交,我得到simple_form_for NilClass的未定義方法`model_name':類
simple_form_for爲NilClass未定義的方法`MODEL_NAME」:
類
**_form.html.erb**
<%= simple_form_for(@calls) do |f| %>
<%= f.error_notification %>
<%= f.input :caller_name %>
<%= f.input :caller_phone, hint: "xxx-xxx-xxxx" %>
<%= f.input :caller_address %>
<%= f.input :primary_diagnosis %>
<%= f.error :base %>
<%= f.button :submit %>
<% end %>
**calls_controller.rb**
def create
@call = Call.new(params[:call])
respond_to do |format|
if @call.save
format.html { redirect_to @call, notice: 'Call was successfully created.' }
format.json { render json: @call, status: :created, location: @call }
else
format.html { render action: "new" }
format.json { render json: @call.errors, status: :unprocessable_entity }
end
end
end
**new.html.erb**
<h1>New Call</h1>
<%= render 'form' %>
<%= link_to 'Back', calls_path %>
我在一個有點丟在這裏,因爲我已經跟着軌命名約定,甚至用同樣的結果用腳手架試過。已經重新啓動了webrick。幫幫我?