RailsCasts Pro episodes are now free!

Learn more or hide this

Phill Kenoyer's Profile

GitHub User: Phill

Site: http://phill.kenoyer.com/

Comments by Phill Kenoyer

Avatar

Never mine. I was doing it wrong. It works fine.

Avatar

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:

ruby
def create
  @book = Book.new(params[:book])
  params[:author_tokens].split(',').each do |author|
    @book.authors << Author.find(author)
  end
  ...
end