lundi 10 juillet 2023

problem save with checkboxes on devise registration user

Screenshot servor error [[[[enter image description here](https://i.stack.imgur.com/iVruu.png)](https://i.stack.imgur.com/4lvVr.png)](https://i.stack.imgur.com/edF6v.png)](https://i.stack.imgur.com/Vv59n.png) When I am in local /users/sign_up, I added a checkboxes type field so that the user can select game categories. When I am in my console, the creation of a user is done correctly by selecting my categories in my "favorites_games" array. When I'm on my sign_up page locally, when I select my categories by clicking on my checkboxes, it doesn't save. It tells me "favorites games can't be blank" and I see that an empty string is inserted before my category selections and that causes a rollback in my server.

I tried to insert in the create and new method in the users controller, a method to delete the first index of the favorites_games array. I also tried in my strong params, to write in two ways the argument favorites_games ==>:favorites_games and favorites_games: []. In my User model, I tried to insert in my validations: validates:favorites_games, allow_blank, inclusion {in:Event::CATEGORIES}. In my html.erb file, I tried to put "mulitple: true" as well as include_hidden: true but it doesn't work.




Aucun commentaire:

Enregistrer un commentaire