简体   繁体   中英

Uninitialized constant Version (NameError) when starting Rails server

So I had my app working just fine and then I had to migrate it over to a new development server. I copied all the files over, ran bundle install with no errors and then when I run rails server

I get this error.

=> Ctrl-C to shutdown server
Exiting
C:/Sites/mysite/app/admin/version.rb:1:in <top (required)>': uninitialized con stant Version (NameError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0. 5.1/lib/active_admin/application.rb:190:inblock in load!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0.
5.1/lib/active_admin/application.rb:190:in each' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0. 5.1/lib/active_admin/application.rb:190:inload!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0.
5.1/lib/active_admin/application.rb:213:in routes' from C:inroutes'
from C:/Sites/mysite/config/routes.rb:13:in `block in '
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.11/lib/action_dispatch/routing/route_set.rb:282:in instance_exec' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2 .11/lib/action_dispatch/routing/route_set.rb:282:ineval_block'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.11/lib/action_dispatch/routing/route_set.rb:260:in draw' from C:/Sites/mysite/config/routes.rb:1:in'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/application/routes_reloader.rb:40:in block in load_paths' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/application/routes_reloader.rb:40:ineach'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/application/routes_reloader.rb:40:in load_paths' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/application/routes_reloader.rb:16:inreload!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/application.rb:108:in reload_routes!' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0. 5.1/lib/active_admin/reloader.rb:34:inreload!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0.
5.1/lib/active_admin/reloader.rb:61:in block in attach!' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 3.2.11/lib/active_support/callbacks.rb:429:in_run__334365865__prepare__8021230
81__callbacks'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.11/lib/active_support/callbacks.rb:405:in __run_callback' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 3.2.11/lib/active_support/callbacks.rb:385:in_run_prepare_callbacks'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.11/lib/active_support/callbacks.rb:81:in run_callbacks' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2 .11/lib/action_dispatch/middleware/reloader.rb:74:inprepare!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.11/lib/action_dispatch/middleware/reloader.rb:48:in prepare!' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/application/finisher.rb:47:inblock in module:Finisher'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/initializable.rb:30:in instance_exec' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/initializable.rb:30:inrun'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/initializable.rb:55:in block in run_initializers' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/initializable.rb:54:ineach'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/initializable.rb:54:in run_initializers' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/application.rb:136:ininitialize!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/railtie/configurable.rb:30:in method_missing' from C:/Sites/mysite/config/environment.rb:5:in'
from C:/Sites/mysite/config.ru:3:in block in <main>' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib /rack/builder.rb:51:ininstance_eval'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib
/rack/builder.rb:51:in initialize' from C:/Sites/mysite/config.ru:innew'
from C:/Sites/mysite/config.ru:in <main>' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib /rack/builder.rb:40:ineval'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib
/rack/builder.rb:40:in parse_file' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib /rack/server.rb:200:inapp'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/commands/server.rb:46:in app' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib /rack/server.rb:304:inwrapped_app'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib
/rack/server.rb:254:in start' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/commands/server.rb:70:instart'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/commands.rb:55:in block in <top (required)>' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/commands.rb:50:intap'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
1/lib/rails/commands.rb:50:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

Any clue what's going on here?

EDIT: Code Inside app/admin/version.rb

ActiveAdmin.register Version do


end

EDIT: Routes.rb Code

Mysite::Application.routes.draw do

  ActiveAdmin.routes(self)

  devise_for :users

  get 'application/index'
  root :to => 'application#index'

end

Do you have version.rb model. If not then first generate model

rails generate model version name:string

It will create model and migration for version, add columns of your choice in following code.

20150514124720_create_versions.rb

class CreateVersions < ActiveRecord::Migration  
  def change
    create_table :versions do |t|
      t.string :name
      # also add other attributes of your choice here
      t.timestamps
    end
  end
end

And, then run migration

rake db:migrate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM