Question

I have an Ruby 2 Rails 4 application generated by Rails Composer with Devise and Rolify. I am trying to rename the Devise User model, so I wanted to destroy it and generate it. However, I am getting errors trying to do so related to Rolify. I’ve made several attempts to destroy Rolify with no success and cannot get past that point so that I can work with Devise.

I am going to show several attempts to resolve this problem, along with the errors I get. Each attempt started with a fresh copy of the application. I show the error streams, only.

I basically have two questions: 1. How do I destroy rolify? 2. Is there a better way to rename the devise User model? I thought I found another way but, for the life of me, I can’t find it again..

Destroy rolify, the result being a failed attempt to subtract role.rb after it was removed.

rails destroy rolify Role User
      invoke  active_record
      remove    app/models/role.rb
      invoke    rspec
      remove      spec/models/role_spec.rb
      invoke      factory_girl
      remove        spec/factories/roles.rb
    subtract    app/models/role.rb
D:/BitNami/rubystack-2.0.0-11/ruby/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:98:in `binr
ead': No such file or directory - D:/BitNami/rubystack-2.0.0-11/projects/workingapp/app/models/role.rb (Errno::ENOENT)

Destroy devise model, generate devise model and generate rolify

rails destroy devise user 
rails generate devise device
rails generate rolify Role Device.
      invoke  active_record
The name 'Role' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.

Destroy devise model, generate devise model, delete app/models/role.rb and generate rolify

rails destroy devise user 
rails generate devise device
del app/models/role.rb
rails generate rolify Role Device.
D:/BitNami/rubystack-2.0.0-11/ruby/lib/ruby/gems/2.0.0/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:
226:in `const_get': uninitialized constant Role (NameError)
Was it helpful?

Solution

I haven't been able to find anyway to do this. Backing off Rolify just doesn't seem to work. I've decided to use Rails Composer to create the application without Devise, Rolify and CanCan, then generate each of them individually with my desired model names and configurations. Then, I can migrate all of the code of written into that application and modify it. It's not an easy answer, but it seems to be the best choice...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top