Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

No 'uninitialized constant' thrown when referencing AR class

#6301

'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

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

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Erik van Eykelen
    Erik van Eykelen

    I've tested this again under 1.9.2 and 3.0.4 and I cannot reproduce this issue anymore.

    February 17th, 2011 @ 08:51 AM