Validation failed Class must exist
问题 I have been (hours) trouble with associations in Rails. I found a lot of similar problems, but I couldn't apply for my case: City's class: class City < ApplicationRecord has_many :users end User's class: class User < ApplicationRecord belongs_to :city validates :name, presence: true, length: { maximum: 80 } validates :city_id, presence: true end Users Controller: def create Rails.logger.debug user_params.inspect @user = User.new(user_params) if @user.save! flash[:success] = "Works!" redirect