Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10642 (closed defect: duplicate)

Opened 2 years ago

Last modified 2 years ago

"wrong constant name" exception for association extensions defined in modules

Reported by: mikhailian Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: major Keywords: 2.0.2
Cc:

Description

This does not work

require 'rubygems'
require 'activerecord'

module FooBar
	class Foo < ActiveRecord::Base
		has_many (:bars) do
			def [](name)
				find(:all, :conditions => ["name = ?", name])
			end
		end
	end

	class Bar < ActiveRecord::Base
	end

end

and this works

require 'rubygems'
require 'activerecord'

# module FooBar COMMENTED!!!
	class Foo < ActiveRecord::Base
		has_many (:bars) do
			def [](name)
				find(:all, :conditions => ["name = ?", name])
			end
		end
	end

	class Bar < ActiveRecord::Base
	end

end

Change History

12/29/07 00:22:55 changed by mikhailian

Er... remove the extra "end" at the end of the second snippet to make it work ;-)

12/29/07 01:21:48 changed by fxn

  • status changed from new to closed.
  • resolution set to duplicate.

We've commented this one on #rails-contrib, it duplicates #9284 and #6450.