ruby on rails - undefined local variable or method `admins_root_path' -


i have issue rails code, try create new location based on input. create method looks this:

  def create     @location = location.new(params[:location])      respond_to |format|       if @location.save         # format.html { redirect_to @location, notice: 'location created.' }         format.html { redirect_to admins_root_path, notice: 'location 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 

it ends following error output:

undefined local variable or method `admins_root_path' #<locationscontroller:0x007fa18917f278> app/controllers/locations_controller.rb:47:in `block in create' app/controllers/locations_controller.rb:45:in `create' 

any helpful.

admins_root_path doesn't have defined route. following define named match route it:

match 'path/to/admin/root' => 'admins#root_action', :as => 'admins_root' 

more likely, however, you're invoking wrong route. instance, it's possible trying route admins#index action, in case you'd following:

format.html { redirect_to admins_path, notice: 'location created.' } 

Comments