run rails generate devise:views from "."
/app/models/user.rb:2:in `<class:User>': undefined local variable or method `rolify' for User:Class (NameError)
from /app/models/user.rb:1:in `<top (required)>'
rolify need to be after the includ mongoid. But this error stops the completion of the generator. I figured I could specify no cancan and rolify getting it to work. It does generate but then fails on invitation_token not found. I am about to give up as there seems to be issues with this generator.
@dhf0820 for the fails on invitation_token,
It works for me when the User Model has these field:
@dhf0820 and @l4u thanks for your patience and understanding, I can't test all possible combinations of the preferences, so I appreciate that you brought this error to my attention. I've updated the application template to correct the error. Please test and let me know if the issue is resolved.
It doesnt work for me still
Yes, it also doesn’t work for me. I was able to add the controller after I moved rolify below include Mongoid::Document as suggested above, but can I somehow continue the template after that?
When I answer n to the CanCan & Rolify question, it works for me. I don’t expect it to be too difficult to incorporate those after the fact.
The problem is that Rolify 3.1 (which is required by the template) has an issue with Mongoid, causing the generation process to fail. The issue has been fixed in Rolify 3.2.0.beta4.
Until Rolify 3.2.0.final is released, an acceptable workaround could be to prepend the call to rolify in the user model with include Mongoid::Document, as you can see here. I think it should be easy to do this using gsub_file in the AddUser recipe, right after the call to generate 'rolify:role Role User mongoid'
generate 'rolify:role Role User mongoid'
This solved the issue for me
I've updated rails_apps_composer and the application templates to incorporate your suggestions. Please test and let me know if the issue is resolved. Thanks for your help and patience!
Yes, it works for me now, thanks!
@backspace Thanks for the feedback. I'll close the issue.