构建基本表单以创建新数据时收到以下错误。当我点击提交时,我得到
simple_form_for NilClass:Class 的未定义方法“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 %>
我在这里有点迷茫,因为我遵循了 Rails 命名约定,甚至尝试使用具有相同结果的脚手架。已经重新启动了webrick。帮助?