andy4thehuynh
andy4thehuynh

Reputation: 2172

I ran rails generate devise MODEL before rails generate devise:install

I accidentally added my Devise model before running the initial Devise generator.

Code I ran first:

$ rails generate devise MODEL

Initial Devise generator (what I should have ran first):

$ rails generate devise:install

I now have a devise controller called Model that won't let me run 'rake db:migrate'

Error:

rake aborted!
    User does not respond to 'devise' method. This usually means you haven't loaded your ORM file or  it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside      'config/initializers/devise.rb' or before your application definition in 'config/application.rb'
    /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327/gems/devise-2.2.3/lib/devise/rails/routes.rb:443:in `raise_no_devise_method_error!'
    /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327/gems/devise-2.2.3/lib/devise/rails/routes.rb:211:in `block in devise_for'
    /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327/gems/devise-2.2.3/lib/devise/rails/routes.rb:207:in `each'
    /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327/gems/devise-2.2.3/lib/devise/rails/routes.rb:207:in `devise_for'
    /Users/andyHuynh/Code/jargon/config/routes.rb:3:in `block in <top (required)>'
    /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327@global/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
    /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327@global/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
    /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327@global/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:260:in `draw'
    /Users/andyHuynh/Code/jargon/config/routes.rb:1:in `<top (required)>'
...

Is there a way I can undo this process to run the initial generator first? I am using Rails 3.2.12. Any help is appreciated. Thanks

Upvotes: 7

Views: 8937

Answers (2)

Rashid
Rashid

Reputation: 31

rails destroy model devise:user or rails destroy scaffold devise:user

Upvotes: 3

Jon Cairns
Jon Cairns

Reputation: 11951

You can undo generation commands with rails destroy ..., so in your case it would be:

$ rails destroy devise MODEL

If that doesn't work for whatever reason, you can just delete the model and migration - they're only files.

Upvotes: 21

Related Questions