我有我的rails代碼的問題,我嘗試基於輸入創建一個新的位置。 所以create方法是這樣的:未定義的本地變量或方法`admins_root_path'
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'
任何幫助將是非常有益的。
請張貼'耙的輸出routes' – vee
列表你的路由文件PLZ。 –