title: Invalid single-table inheritance type:
body: <p>I'm getting this error and I don't know what to do. It says </p>
  
  <pre><code>Invalid single-table inheritance type: 1 is not a subclass of Game
  </code></pre>
  
  <p>It says that this error is occuring at the 9 in games_controller.rb. </p>
  
  <p>i.e.</p>
  
  <pre><code>   @game = current_user.created_games.build(game_params)
  </code></pre>
  
  <p>I don't understand what is happening and what I should write here to specify the cause of this error. I copy&amp;paste <strong>game.rb</strong>, <strong>user.rb</strong>, <strong>application_controller.rb</strong> and <strong>games_controller.rb</strong> here.</p>
  
  <p><strong>game.rb</strong>  is</p>
  
  <pre><code>class Game &lt; ActiveRecord::Base
    belongs_to :owner, class_name: 'User'
  end
  </code></pre>
  
  <p><strong>user.rb</strong> is</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_many :created_games, class_name: 'Game', foreign_key: :owner_id
  
    def self.find_or_create_from_auth_hash(auth_hash)
      provider = auth_hash[:provider]
      uid = auth_hash[:uid]
      nickname = auth_hash[:info][:nickname]
      image_url = auth_hash[:info][:image]
  
      User.find_or_create_by(provider: provider, uid: uid) do |user|
        user.nickname = nickname
        user.image_url = image_url
      end
    end
  end
  </code></pre>
  
  <p><strong>application_controller.rb</strong> is</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception
  
    helper_method :logged_in?
  
    private
  
    def current_user
      return unless session[:user_id]
      @current_user ||= User.find(session[:user_id])
    end
  
    def logged_in?
      !!session[:user_id]
    end
  
    def authenticate
      return if logged_in?
      redirect_to root_path, alert:'Please log in.'
    end
  
    def created_by?(user)
      return false unless user
      owner_id == user.id
    end
  end
  </code></pre>
  
  <p><strong>games_controller.rb</strong></p>
  
  <pre><code>class GamesController &lt; ApplicationController
    before_action :authenticate
  
    def new
      @game = current_user.created_games.build
    end
  
    def create
      @game = current_user.created_games.build(game_params)
      if @game.save
        redirect_to @game, notice: 'You created game.'
      else
        render :new
      end
    end
  
    private
  
    def game_params
      params.require(:game).permit(
        :name, :content, :type
      )
    end
  end
  </code></pre>
  
  <p><strong>Added</strong></p>
  
  <p><strong>new.html.erb</strong></p>
  
  <pre><code>&lt;% now = Time.zone.now %&gt;
  &lt;div class="page-header"&gt;
    &lt;h1&gt;Create Game&lt;/h1&gt;
  &lt;/div&gt;
  
  &lt;%= form_for(@game, class: 'form-horizontal', role:'form') do |f| %&gt;
    &lt;% if @game.errors.any? %&gt;
      &lt;div class="alert alert-danger"&gt;
        &lt;ul&gt;
        &lt;% @game.errors.full_messages.each do |msg| %&gt;
          &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  
    &lt;div class="form-group"&gt;
      &lt;%= f.label :name %&gt;
      &lt;%= f.text_field :name, class: 'form-control' %&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.label :type %&gt;
      &lt;div&gt;
        &lt;%= f.select :type, options_for_select: [['basic', 1]], class: 'form-control' %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.label :content %&gt;
      &lt;%= f.text_area :content, class: 'form-control', row: 10 %&gt;
    &lt;/div&gt;
    &lt;%= f.submit 'Create', class: 'btn btn-default', data: { disable_with: 'Creating...' } %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>When I try to create new game, console says as follows.</p>
  
  <pre><code>Started POST "/games" for 127.0.0.1 at 2015-01-29 01:50:29 +0900
  Processing by GamesController#create as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"2W57cDKT2552Xgnh2MLi17uQpcrqDkmxhQJQa1qNuJNsZb0R10l/AU37y+KO9DysCp56aVTFBE/MqRoimMnjYQ==", "game"=&gt;{"name"=&gt;"this is name", "type"=&gt;"1", "content"=&gt;"this is content"}, "commit"=&gt;"Create"}
    User Load (0.6ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 1]]
  Completed 500 Internal Server Error in 32ms
  
  ActiveRecord::SubclassNotFound - Invalid single-table inheritance type: 1 is not a subclass of Game:
  </code></pre>