我的 Rails 代码有问题,我尝试根据输入创建一个新位置。因此 create 方法如下所示:
def create
@location = Location.new(params[:location])
respond_to do |format|
if @location.save
# format.html { redirect_to @location, notice: 'Location was successfully created.' }
format.html { redirect_to admins_root_path, notice: 'Location was successfully created.' }
format.json { render json: @location, status: :created, location: @location }
else
format.html { render action: "new" }
format.json { render json: @location.errors, status: :unprocessable_entity }
end
end
end
它以以下错误输出结束:
undefined local variable or method `admins_root_path' for #<LocationsController:0x007fa18917f278>
app/controllers/locations_controller.rb:47:in `block in create'
app/controllers/locations_controller.rb:45:in `create'
任何帮助都会非常有帮助。