Forum: Typo const_missing when loading sidebar_controller

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ae577905a543a759b11ce883ffd00ef6?d=identicon&s=25 Sean Mountcastle (Guest)
on 2006-03-15 17:33
(Received via mailing list)
Has anyone else seen this issue in their development log for Typo?
Normally, the side bar still renders ok, but since I have a
before_filter in my ApplicationController that sets up a variable
which the SidebarController is using now the sidebar fails to
renderer.

Any ideas why Ruby cannot find the ApplicationController when loading
the SidebarController?  From the stack trace below it looks like I
might have a circular dependency -- its started to load
ApplicationController but the trace is as follows:

ApplicationController has "model :account"
Account has "has_many :sidebars, :order => "controller ASC",
:class_name => "Sidebar", :foreign_key => 'account_id'"
Sidebar has "require_dependency 'sidebars/sidebar_controller'"
SidebarController is a subclass of ApplicationController

Any ideas on how to get around this while still keeping the has_many
relationship with Account?

NameError (uninitialized constant ApplicationController):
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:200:in
`const_missing'
    /components/sidebars/sidebar_controllerrb:1
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:207:in
`load'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:39:in
`require_or_load'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:22:in
`depend_on'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:178:in
`require_dependency'
    /app/models/sidebarrb:1
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:207:in
`load'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:39:in
`require_or_load'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:22:in
`depend_on'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:30:in
`associate_with'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:179:in
`require_association'
    /usr/lib/ruby/gems/18/gems/activerecord-1132/lib/active_record/associationsrb:780:in
`require_association_class'
    /usr/lib/ruby/gems/18/gems/activerecord-1132/lib/active_record/associationsrb:355:in
`has_many_without_reflection'
    (eval):5:in `has_many'
    /app/models/accountrb:17
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:207:in
`load'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:39:in
`require_or_load'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:22:in
`depend_on'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:178:in
`require_dependency'
    /usr/lib/ruby/gems/18/gems/actionpack-1112/lib/action_controller/dependenciesrb:72:in
`require_dependencies'
    /usr/lib/ruby/gems/18/gems/actionpack-1112/lib/action_controller/dependenciesrb:70:in
`require_dependencies'
    /usr/lib/ruby/gems/18/gems/actionpack-1112/lib/action_controller/dependenciesrb:35:in
`model'
    /app/controllers/applicationrb:6
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:207:in
`load'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:39:in
`require_or_load'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:22:in
`depend_on'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:178:in
`require_dependency'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:134:in
`load_file!'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:97:in
`const_load!'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:80:in
`const_load!'
    /usr/lib/ruby/gems/18/gems/rails-100/lib/dispatcherrb:71:in
`prepare_application'
    /usr/lib/ruby/gems/18/gems/rails-100/lib/dispatcherrb:37:in
`dispatch'
    /usr/lib/ruby/gems/18/gems/rails-100/lib/webrick_serverrb:117:in
`handle_dispatch'
    /usr/lib/ruby/gems/18/gems/rails-100/lib/webrick_serverrb:83:in
`service'
    /usr/lib/ruby/18/webrick/httpserverrb:104:in `service'
    /usr/lib/ruby/18/webrick/httpserverrb:65:in `run'
    /usr/lib/ruby/18/webrick/serverrb:173:in `start_thread'
    /usr/lib/ruby/18/webrick/serverrb:162:in `start_thread'
    /usr/lib/ruby/18/webrick/serverrb:95:in `start'
    /usr/lib/ruby/18/webrick/serverrb:92:in `start'
    /usr/lib/ruby/18/webrick/serverrb:23:in `start'
    /usr/lib/ruby/18/webrick/serverrb:82:in `start'
    /usr/lib/ruby/gems/18/gems/rails-100/lib/webrick_serverrb:69:in
`dispatch'
    /usr/lib/ruby/gems/18/gems/rails-100/lib/commands/servers/webrickrb:59
    /usr/lib/ruby/site_ruby/18/rubygems/custom_requirerb:21:in `require'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:214:in
`require'
    /usr/lib/ruby/gems/18/gems/rails-100/lib/commands/serverrb:28
    /usr/lib/ruby/site_ruby/18/rubygems/custom_requirerb:21:in `require'
    /usr/lib/ruby/gems/18/gems/activesupport-125/lib/active_support/dependenciesrb:214:in
`require'
    /script/server:3
This topic is locked and can not be replied to.