HABTM and collection_select


I’m trying to use collection_select with a habtm relationship. Let’s say
you have two tables: books and authors with a many-to-many relationship.

Is there any way in rails to render something like selection boxes for
each author, so that the user can change them?

I tried this (and several more variations) but it doesn’t work:

<% for @author in @book.authors %>
<%= collection_select(“author[]”, “author_id”, @authors, :id,
:full_name) %>
<% end %>

Is it possible to use collection select for this ?

Thanks in advance,

  • Juancho

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs