Cities#new controller shows error involving cities_path, but I don't have it in any file nor in CitiesController. I checked all files, tried to restart the server but still nothing.
undefined method `cities_path' for #<#<Class:0x007f9e4c1cb348>:0x00000003836140> Did you mean? city_path CitiesController
class CitiesController < ApplicationController def index @cities = City.all end def show find_city end def new @city = City.new end def edit find_city end def update find_city if @city.save redirect_to city_path(@city) else render "edit" end end def create @city = City.new(city_params) if @city.save redirect_to index_path else render "new" end end private def find_city @city = City.find(params[:id]) end def city_params params.require(:city).permit(:name, :icon_url) end end Routes
get "/cities/new" => "cities#new", as: "new_city" post "/index" => "cities#create" get "/cities/:id" => "cities#show", as: "city" get "/cities/:id/edit" => "cities#edit", as: "edit_city" patch "/city/:id" => "cities#update" Form (error is raised on first line)
<%= form_for @city do |f| %> <% if @city.errors.any? %> <div class="errors"> <ul> <% city.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <%= f.label "Name:" %> <%= f.text_field :name, class: "form-control" %> <%= f.label "Icon:" %> <%= f.text_field :icon_url, class: "form-control" %> <%= f.submit "Pošalji" %> <% end %>
/index, while everything else is scoped to/cities. Your cities index route should really be/cities, not/index.