vendredi 10 avril 2020

unpermitted param when using checkbox but not when using text_area

i want to save a value into database via a checkbox as array. when trying to do this the console log tells me that :skills is not permitted. When using the text_field helper it works.

My view:

        <% skills = ["Coding", "Design", "Petting Cats"] %>
        <% skills.each do |skill| %>
        <%= dd.check_box :skills, { multiple: true }, skill, false %>
        <% dd.label skill %>
        <% end %>

skills is in the accounts table which model belongs to user. Everything else works btw.

My users_controller params:


    def user_params
        params.require(:user).permit(:email, :password, :password_confirmation, :account, 
            account_attributes:[:id, :username, :skills, :description, :location, :avatar, :tags, :tags])
    end

Console Log:

  ↳ app/controllers/users_controller.rb:15
Unpermitted parameter: :skills

Line 15 refers to the update action.

When using the checkbox as boolean, its possible to store data, even though i want to use it for strings as array. any suggestions?




Aucun commentaire:

Enregistrer un commentaire