Have you looked this tutorial http://www.buildingwebapps.com/podcasts/6789-resources-page-links-categories-and-habtm/show_notes (download the second link source code.)
Again, I’m new, so take this for what its worth…
Notice in their create method for pages and links (the two that have the habtm relationship) there is no need to add the collection to the main object. It looks like you shouldn’t need:
@recipe.category_recipe_ids<<(params[:category_recipe_ids])
You should just be able to use
@recipe = Recipe.new
And it should pull in the selected categories from your select options.
Not sure if it matters but in the example posted they are using a different select tag than you’re using:
<%= f.collection_select :category_ids, Category.find(:all, :order => ‘title’), :id, :title, {}, :multiple => true %>
Actually looking at your select tag I’m not sure how something like “recipe_ids” would be set the way you have it:
<%= select_tag ‘category_recipe_ids’, options_from_collection_for_select(@categories, :id, :title), { :multiple => true, :size =>5, :id => “categories_recipes_id” } %>
Why not try something like have shown:
<%= f.collection_select :category_ids, Recipe.find(:all), :id, :title, {}, :multiple => true %>
Also if you were going to be setting the categories in recipes (which I don’t think you need to do anyway), wouldn’t it be something like
@recipe.category_ids <<(params[:category_ids])
I don’t think you’d set the category_recipe_id ? (Again, I’m new so I could be way off here.)