0

I am trying to debug my log's with the following line:

<%= debug $pvp_user.pvp_death_logs %>

The error I am receiving:

Unable to autoload constant PvpDeathLog, expected /var/www/rails/ourapp/app/models/pvp_death_log.rb to define it

models/pvp_user.rb

class Pvp_user < ActiveRecord::Base
    has_many :pvp_death_logs
end

models/pvp_death_log.rb

class Pvp_death_log < ActiveRecord::Base
    belongs_to :pvp_user
end

controllers/player_controller.rb

class PlayerController < ApplicationController
  def index
  end

  def show
    user = Mc_user.find_by username: params[:id]
    if !user
        flash[:status] = FALSE
        flash[:alert] = 'we couldn\'t find that user.'
    else
        pvp_user = Pvp_user.find_by username: params[:id]
        if !pvp_user
            flash[:status_pvp] = FALSE
            flash[:alert_pvp] = 'No player vs player profile found.'
        else
            flash[:status_pvp] = TRUE
            $pvp_user = pvp_user
        end

        flash[:status] = TRUE
        $user = user
    end
  end
end

views/player/show.html.erb

<%= debug $pvp_user.pvp_death_logs %>

Mysql database: pvp_users http://i.imgur.com/9LViwVG.png

Mysql database: pvp_death_log http://i.imgur.com/A9WfPu4.png

4

1 回答 1

2

Your classes' naming is inconsistent with Ruby standards. Classes and modules names should be in CamelCase:

class PvpUser
  # (...)
end

class PvpDeathLog
  # (...)
end
于 2013-10-23T14:11:58.817 回答