I think the What’s new in Ecto 2.0 ebook covers this?
But in a nutshell, I think you need to do something like this:
permissions = Repo.all from p in Permission, where: p in ^params["permissions_ids"]
role
|> changeset(...)
|> put_assoc(:permissions, permissions)