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

Ticket #6795 (closed defect: duplicate)

Opened 3 years ago

Last modified 2 years ago

[PATCH] Rails::Initializer::load_observers assumes ActiveRecord framework

Reported by: jason Assigned to: core
Priority: low Milestone: 1.x
Component: Railties Version: 1.2.0rc1
Severity: minor Keywords: 1.2regression
Cc:

Description

My rails app does not use ActiveRecord. The 1.2.0rc1 implmentation of Initializer::load_observers raises a const_missing NameError.

a patch could look like this:

    def load_observers
      return unless configuration.frameworks.include?(:active_record)
      ActiveRecord::Base.instantiate_observers
    end

Change History

12/18/06 20:27:41 changed by david

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

Observers are an ActiveRecord feature. If you have your own concept of observers, you'll want to load them by hand some how. config.observers is specifically to trigger the active record ones.

03/25/07 17:28:19 changed by adh1003

  • status changed from closed to reopened.
  • resolution deleted.

I'm reopening this for consideration because I think the original report was misread. The reporter was not asking to use Observers. The problem is that this:

{{{Rails::Initializer.run do |config|

config.frameworks -= [ :active_record ]

end}}}

...causes Rails 1.2[.2] to fail, whereas Rails 1.1.2-1.1.6 worked OK with that. The original reporter has traced the problem to a section of code which should be checking to see if ActiveRecord is being included, but does not do so.

A similar fault report exists in Ticket #7868. The last entry for this ticket says that removing database.yml causes ActiveRecord to disable itself, but this appears to be incorrect. As in previous versions of Rails, omitting the database configuration file causes a read error that prevents application startup.

Presently, applications that want to use the Rails framework without a database connection (e.g. Subversion or CVS visualisation applications that want the Rails views mechanism - that's my particular application) fail under Rails 1.2. There is no workaround except to create a fake database for them. But that's really inefficient.

I agree this is low priority, but could not the patch given by the original reporter be included? Other parts of Rails really do check to ensure that ActiveRecord is included, so the fact that the Observer code doesn't looks very much like a genuine bug (with apparently a really simple fix).

Thanks! :-)

08/08/07 14:52:01 changed by lifofifo

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

This was fixed in [6819]