I have a problem with an audited gem. It's two problems in one. I installed and configured the audited gem in my application, but when I delete the database and run migrate and seed again, the user_id and user_type fields in the database are NULL in addition, when I register a user through devise sign_up (new_registration_path) the user_id and user_type are also registered as NULL in the database, which causes an error, as can be seen in the image or here:
undefined method `name' for nil:NilClass
The error line is this:
<%= f.select :user_name_cont, Audity.all.map { |u| [u.user.name] }.uniq, include_blank: true %>
I already put in my Audity model a belongs_to optional: true, but still the error continues.
My application is on my github: https://github.com/eltonsantos/auth-rails
How do I resolve this error? The solution I think is when running the seed or registering a new user, run an after_save or an after_create putting some default id in the user_id field (maybe his own id), but I'm not sure if it's the best solution.