简体   繁体   中英

Error when launching rails server - getting “uninitialized constant Devise::Models::Invitable (NameError)”

I am new to rails and am trying to follow along with this prelaunch signup tutorial - http://railsapps.github.com/tutorial-rails-prelaunch-signup.html

When initializing the rails server using $ rails s, I get the following error message:

Users/pv/.rvm/gems/ruby-1.9.3-p194@rails326/gems/devise-2.1.2/lib/devise/models.rb:97:in `const_get': uninitialized constant Devise::Models::Invitable (NameError)

followed by a bunch of file paths, such as:

from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/devise-2.1.2/lib/devise/models.rb:97:in `block (2 levels) in devise'
from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/devise-2.1.2/lib/devise/models.rb:92:in `each'
from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/devise-2.1.2/lib/devise/models.rb:92:in `block in devise'
from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/devise-2.1.2/lib/devise/models.rb:123:in `devise_modules_hook!'
from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/devise-2.1.2/lib/devise/models.rb:90:in `devise'
from /Users/patrickvihtelic/code/rails-prelaunch-signup/app/models/user.rb:5:in `<class:User>'
from /Users/patrickvihtelic/code/rails-prelaunch-signup/app/models/user.rb:1:in `<top (required)>'
from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize'
from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
from /Users/patrickvihtelic/.rvm/gems/ruby-1.9.3-p194@rails326/gems/devise-2.1.2/lib/devise.rb:256:in `get'

Can anyone please give me a hint or point me in the right direction?

Thanks!

Pat

You need to add:

require 'devise_invitable'

to config/initializers/devise.rb. That will get rid of this error.

The "list of file paths" you got is called a "stack trace." It starts at the top showing the line number and file where the error occurred. Subsequent lines are the function which was calling the function where the error occurred, then the function which called that, and so on. That helps you figure out, if the error was due to bad input, where the trouble began.

In this case, you're trying to call in to the Devise engine, and it's objecting to a name you used. In this case, it's in Devise's Models module. Looking at the documentation for that module, I see that there is no Invitable module or class defined. You might want to look at this question .

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