load_missing_constant

11 vues
Accéder directement au premier message non lu

Erwin

non lue,
21 oct. 2012, 05:33:5921/10/2012
à Ruby on Rails: Talk
I have a model 'site' defined in a sub-folder 'cms'
class Cms::Site < ActiveRecord::Base
.....

the model is loaded correctly , checked in console:
application.rb
config.autoload_paths += Dir["#{config.root}/app/models/**/"]

console
>Cms::Site.all => []

Now trying to access this model from a sites_controller ( in
backoffice/cms subfolder, action: index ) I get the
load_missing_constant error, aslking for the model to define Site and
not Cms::Site... where am I wrong ? or did I missed any initializing
parameter ?

backoffice/cms/sites_controller.rb
class Backoffice::Cms::SitesController < ApplicationController
def index
@sites = Cms::Site.all
end

LoadError in Backoffice::Cms::SitesController#index
Expected /Users/..../app/models/cms/site.rb to define Site
(activesupport (3.2.8) lib/active_support/dependencies.rb:503:in
`load_missing_constant')

Erwin

non lue,
21 oct. 2012, 05:55:2021/10/2012
à Ruby on Rails: Talk
should it not be related to the nested
namespace :backoffice :cms ? I'll try to change it
to :backoffice :cms_admin
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message