search for: recipe_categories

Displaying 2 results from an estimated 2 matches for "recipe_categories".

2006 Jun 20
0
options_from_collection_for_select question
I am doing the recipe/category example, but with a has_many_and_belongs_to relationship. To select categories for a recipe, I have a select control. When editing, I want the proper categories selected. In order to get it to work, I put this in my _form.rhtml: <select id="recipe_categories" name="recipe[category_ids][]" size="4" multiple> <%= options_from_collection_for_select( @categories, ''id'', ''name'', @recipe.categories.map{|t| t.id}) %> </select> Is this the best way to do this? ~S
2006 Jun 18
6
integer array columns
Postgres database. I have a categories table, with two columns id, and name. I have a recipes table, with a category_ids column. I want each recipe to belong to one or more category. in recipe_controller.rb I have this: def create @recipe = Recipe.new( @params[''recipe''] ) @recipe.category_ids = @params[''recipe''][''category_ids''].map{