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

class User < ActiveRecord::Base
  has_many :posts

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

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=""></a>

People watching this ticket