title: Rails NameError 'uninitialized constand User::Events' using devise
body: <p>I feel like the title could be more specific but I'm having a hard time understanding the issue, and I'm unsure of what the problem is so I apologize.</p>
  <p>I have Users, created with devise, users can make events, and the events have many users associated with them as attendees.</p>
  <p>My user model:</p>
  <pre><code>class User &lt; ApplicationRecord
    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
    devise :database_authenticatable, :registerable,
          :recoverable, :rememberable, :validatable
  
    has_many :created_events, foreign_key: :owner_id, class_name: &quot;Events&quot;
    has_many :attendees, through: :attendees
  
  end
  </code></pre>
  <p>My event model</p>
  <pre><code>class Event &lt; ApplicationRecord
    belongs_to :owner, class_name: 'User'
    has_many :attendees, through: :attendees
  end
  </code></pre>
  <p>My attendee model, to join the two</p>
  <pre><code>class Attendee &lt; ApplicationRecord
    belongs_to :attendee, class_name: &quot;User&quot;
    belongs_to :attended_event, class_name: &quot;Event&quot;
  end
  </code></pre>
  <p>I get the &quot;uninitialized constant User::Events&quot; error when trying to use something like this, going to /users/[:id], in my users_controller file:</p>
  <pre><code>class UsersController &lt; ApplicationController
  
    before_action :authenticate_user!
  
    def show
      @user = User.find(params[:id])
      @created_events = @user.created_events.all
    end
  
  end
  </code></pre>
  <p>or when doing a new &gt; create action in the events_controller file:</p>
  <pre><code>def new
    @event = Event.new
  end
  
  def create
    @event = current_user.created_events.build(event_params)
  
      respond_to do |format|
        if @event.save
          format.html { redirect_to @event, notice: 'Event was successfully created.' }
          format.json { render :show, status: :created, location: @event }
        else
          format.html { render :new }
          format.json { render json: @event.errors, status: :unprocessable_entity }
      end
    end
  end
  </code></pre>
  <p>It worked fine until I added the join model, and now I'm getting the error:</p>
  <pre><code>uninitialized constant User::Events
  </code></pre>
  <p>Thanks in advance. I'm having a really hard time with this.</p>