Hi,
Here’s my problem. I tried to google it, read the release-docs and
haven’t found anything similar.
My application uses folders to store controllers, as described in the
Rails book. I need to have same-named controllers for admin and for
users, so it looks like this:
/app/controllers/admin/project_controller.rb
/app/controllers/admin/…
/app/controllers/project_controller.rb
/app/controllers/…
The controller-classes are properly scoped like this:
/app/controllers/admin/project_controller.rb has:
class Admin::ProjectController < ApplicationController
layout "admin"
def index
...
end
/app/controllers/project_controller.rb has:
class ProjectController < ApplicationController
layout "user"
def index
...
end
Those controllers make use of helpers, and again, there are global
ones (used by both by users and admins), and special ones for admins.
So it looks like this:
/app/helpers/admin/project_helper.rb
/app/helpers/admin/…
/app/helpers/project_helper.rb
/app/helpers/…
The admin helper contains properly scoped content:
module Admin::ProjectHelper
...
end
and normal helper has also:
module ProjectHelper
...
end
It is important, that admin-scope controllers are also accessing and
using constants and classes defined in user-scope helpers. This
worked fine in 0.14.x and in 1.0 versions of Rails. Now I’m trying to
move to 1.1.1 through Locomotive bundle or 1.1.2 through normal means
(sudo gem update rails, …, etc) and this behavour breaks.
The original working code in the admin-controller is like this:
class Admin::ProjectController < ApplicationController
layout "admin"
def index
@project_display_options =
ProjectHelper::ProjectDisplayOptions.new(params, session)
…
and it accessed ProjectDisplayOptions class from the user-scope helper:
module ProjectHelper
class ProjectDisplayOptions
attr_accessor :project
...
Now, in Rails 1.1.x, my application breaks as if the user-helper
scope was unavailable for admin-scope controller:
NameError in Admin/projectController#index
uninitialized constant ProjectDisplayOptions
...
#{RAILS_ROOT}/app/controllers/admin/project_controller.rb:6:in `index'
line 6 leads to:
@project_display_options = ProjectHelper::ProjectDisplayOptions.new
(params, session)
The browser response also contains this:
This error occured while loading the following files:
admin/project_helper/project_display_options.rb
which seems to come from the new dynamic mechanism trying to load an
unknown class from a same-named file. But I’m not sure is this is
really what’s supposed to happen.
I can fix the problem by copying-pasting the problematic class from
user-scope helper to the admin-scope-helper, but this is not DRY, of
course. And what happened, that the behaviour of Rails has changes in
1.1? I can’t find anything relevant in the release-notes.
My application is a small internal tool, but certainly is was running
for the last six months on 0.13, 0.14 and on 1.0 versions of Rails.
Any help? TIA.
–
RafaÅ? Komorowski
[email protected]
GG: 4083718
http://homepage.mac.com/komor/iblog/