n-to-m relationships in Forms

That's easy enough:

Controller:

def edit @movie = Movie.find(params[:id]) @languages = Language.find(:all) end

View:

<label>Languages:</label><br/>        <% @languages .each do |lang| %>           <%= check_box_tag 'movie[language_ids]', lang.id, @movie.languages.include?(lang), :id=>"cb_#{lang.name}" %>           <label for="cb_<%=lang.name%>" class="inline"><%=lang.name%></label><br/>        <% end %>

The trick is in the "movie[language_ids]". Nothing else to do, just do the standard Movie.new(params[:movie]) stuff in your controller and everything should be fine.

Cheers Max

Max, you rock. I create forms like this all the time, and I kept thinking that there must be a better way - and lo and behold, there is.