RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: Phill
Never mine. I was doing it wrong. It works fine.
If the form doesn't pass validation, the tokens are lost and have to be entered again. What would be a clean way to have it keep the tokens on validation errors.
I don't like the way I'm doing it now:
@book = Book.new(params[:book])
params[:author_tokens].split(',').each do |author|
@book.authors << Author.find(author)