Open Zeben opened 7 years ago
I am facing a similar error while upgrading Mongoid from version 5 to 6. Did you get any solution to it @Zeben .
Thanks
Mongoid 6 follows the new pattern of AR5 requiring a belongs_to
relation to always require its parent (see https://github.com/rails/rails/pull/18937/files). So rolify would need to change to have it set or the generation should make it optional, ie:
belongs_to :resource, :polymorphic => true, :optional => true
Thanks a lot Durran. Will try this and keep you posted. Hopefully would be able to resolve the bug.
Regards, Akarsh
On Thu, Mar 2, 2017 at 5:33 PM, Durran Jordan notifications@github.com wrote:
Mongoid 6 follows the new pattern of AR5 requiring a belongs_to relation to always require its parent (see https://github.com/rails/ rails/pull/18937/files). So rolify would need to change to have it set or the generation should make it optional, ie:
belongs_to :resource, :polymorphic => true, :optional => true
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RolifyCommunity/rolify/issues/435#issuecomment-283635695, or mute the thread https://github.com/notifications/unsubscribe-auth/ANDj0G_U8xxjTAqjwOmKzwFTV8pN-fVQks5rhq_7gaJpZM4Lt73i .
Hello Durran. It works for me, thank you many times for the comment. Recently I've deleted this validation but I've tried to restore the line with :optional => true
completion. It works fine now.
But anyway Rolify still doesn't create correct role.rb
template, even with new project creation. Will be fixed this behaviour in Rolify in near future?
Thanks in advance.
Hello everybody. I've got an terrible bug that makes roles creation impossible. There is my steps:
rails new sample --skip-active-record
andcd
intosample
directory;mongoid
,bson_ext
androlify
intoGemfile
;bundle
;rails g mongoid:config
;User
:rails g model user name password_digest
. It works withActiveModel::SecurePassword
, that makes possible usinghas_secure_password
;rails g rolify Role User -o=mongoid
;rails c
command;admin
):Get an exception:
My user.rb file:
... and role.rb file that was generated via
rails g rolify Role User -o=mongoid
:I'm using Mongoid 6.0.3, Rails 5.0.1, bson_ext 1.5.1, and Rolify 5.1.0. The error doesn't occures in project that uses Rails 4.2.1. Please help me to understand where the error can be. Tnanks in advance.