This project is archived and is in readonly mode.

#6301 new
Erik van Eykelen

No 'uninitialized constant' thrown when referencing AR class

Reported by Erik van Eykelen | January 17th, 2011 @ 06:41 PM

'uninitialized constant' is not thrown for the following use case:

class Post < ActiveRecord::Base
  TEST_FOO = 123
  validates_presence_of :title, :message => TEST_FOO_WRONG # <- uninitialized constant!
  belongs_to :user
end

class User < ActiveRecord::Base
  has_many :posts
end

class PostsController < ApplicationController
  def index
    @post = User.first.posts.first # <- No uninitialized constant thrown!
    # @post = Post.first # <- Throws uninitialized constant
    render :text => @post.valid?
  end
end

Tested under Ruby 1.8.7, 1.9.2 and Rails 3.0.3

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages