rails generate devise:views NameError: uninitialized constant View

1.3k views Asked by At

I have followed the #209 tutorial of railscast http://railscasts.com/episodes/209-introducing-devise?view=asciicast. It was working good until I tried to generate the devise views to customize it (tutorial #210 of railscast)

I did :

rails generate devise:views
rails generate devise_views

Got the following error :

NameError: uninitialized constant View

I am using rails 3.1.3, & devise 1.4.7 with warden 1.0.6. Any ideas ?

Tks Matt

2

There are 2 answers

1
Gazler On

You can find out a list of all the generators by running rails generate or rails g

The correct generator is:

rails g devise:views

I can only think that you are having some sort of version conflict.

Does the following work:

bundle exec rails g devise:views

If not, have you already run:

rails g devise:install
rails g devise User
2
counterbeing On

I ran into this issue myself. I accidentally typed rails g devise views which actually created a new model for devise, and added routes for them. I deleted all of the files that were created, then corrected myself and typed rails g devise:views and started getting your exact error.

After a bit of head scratching I ran a git diff to see if anything else was different, and indeed it had added a route for "views". Upon deleting that route, and running rails g devise:views again, all was well!

Hope this helps!