I'm actually posting an Array of ids to my Rails API but the array is received as a hash where the keys are the index of the array.
I already try permitting the parameters params.permit(permission_ids: [])
and nothing...
User migration
class CreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :username, null: false
t.string :email, null: true
t.integer :language_id, null: false
t.integer :permission_ids, array: true, default: []
t.string :password_digest, null: false
t.timestamps
end
add_index :users, :username, unique: true
end
end
User params method in the controller.
def user_params
params.require(:user).permit(:username,
:email,
:language_id,
:password,
:password_confirmation,
permission_ids: [])
end
How parameters are received
Parameters: {"user"=>{"username"=>"someusername", "email"=>"someemail@question.com", "language_id"=>"2", "permission_ids"=>{"0"=>"1", "1"=>"2", "2"=>"3", "3"=>"4", "4"=>"5", "5"=>"6", "6"=>"7", "7"=>"8", "8"=>"9", "9"=>"10", "10"=>"11", "11"=>"12"}}}
By the way, I'm posting from Vue using Axios.