- To pre select the checkboxes with the currently associated authors you can you can add the checked attribute into your input tag; 

    <input name="<%= author.name %>" <%= 'checked' if @book.authors.include? author %> id="author_id"        type="checkbox" value="<%= author.id %>">