why my engine can’t be loaded?
When I startup server console show message:
`load_missing_constant': Expected D:/alexandre/dev/rails/project_name/lib/admin/engine.rb to define Admin::Engine (LoadError)
But “/lib/admin/engine.rb” exists and its contents is:
Admin::Engine.routes.draw do
get '/' => "admin#index"
get '/error' => "admin#error"
post '/thunder' => "thunder#create", :as => "thunders"
get '/:class' => "admin_models#index"
get '/:class/new' => "admin_models#new"
post '/:class' => "admin_models#create"
get '/:class/:id' => "admin_models#show"
get '/:class/:id/edit' => "admin_models#edit"
put '/:class/:id' => "admin_models#update"
delete '/:class/:id' => "admin_models#destroy"
end
In routes I add this line:
mount Admin::Engine => '/admin', :as => 'admin'
Project specification:
- ruby 1.9.2p180
- Rails 3.2.6
The file “/lib/admin/engine.rb”, should define the constant Admin::Engine, or more explicitely that file should define the class Admin::Engine. Here is a minimal example of the content for that file
The snipped you posted before is about the routes of your engine and should therefore be placed in “config/routes.rb”
The documentation and the guide are great ways to get familiar with engines. If you like books, I advise you to read Crafting Rails Applications which is a small but very dense book and talks extensively about engines (and is written by one of the most awesome rubyist : Jose Valim).