search for: categories_product

Displaying 10 results from an estimated 10 matches for "categories_product".

Did you mean: categories_products
2006 Jul 30
1
Doubt on composite index
The AWDwR book has the following: add_index :categories_products, [:product_id, :category_id] add_index :categories_products, :category_id The first, composite index actually serves two purposes: it creates an index which can be searched on both foreign key columns, and with most databases it also creates an index that enables fast lookup by the product id...
2006 May 28
7
Join table not being populated
Hello, I have the usual Categories and Products table scenario, mediated by a Categories_Products join table. When I create a new Product and into a given Category, I notice that my join table is not being populated. Shouldn''t the join Categories_Products table be populated? Thanks, gk -- Posted via http://www.ruby-forum.com/.
2006 Jul 07
2
many-to-many error
...a many-to-many relationship with products and categories. I''ve got the product model (product.rb) set up: class Product < ActiveRecord::Base has_and_belongs_to_many :categories end and a similar one for category.rb And I''ve got the tables set up -- products, categories, categories_products But when I load, I get: undefined method `associate_identification'' for Product:Class. This error occured while loading the following files: product.rb Any thoughts? -- Posted via http://www.ruby-forum.com/.
2006 Jun 05
5
adding habtm through migrations
Hello, I''m stuck, I''ve got a model Product and would like to add a new model called Category. Furthermore, I want to set up a many2many relationship between the mentioned models. the problem is that I do not know how to set the primary key in the categories_products table. this is what I''ve got in my migration file: create_table :categories do |t| t.column :name, :string # Other fields here end create_table :categories_products do |t| t.column :category_id, :integer t.column :product_id, :integer #how do I set the primary key to be (cat...
2005 Jun 03
1
sorting on a habtm relationship
...e of a category using something like acts_as_list. Problem is, since each product can belong to multiple categories, it doesn''t work to use acts_as_list and have the "position" field be in the products table -- I would need to figure out some way to put the position field in the categories_products table. Is there a non-messy way to do this? Right now, I''m thinking about just defining a categories_products model that belongs_to :product, belongs_to :category, and acts_as_list. That exposes some ugly implementation details to the controllers, but I can''t think of anything...
2006 May 01
4
Find rows with associations in habtm
This may have been asked/answered before - if so, i apologise... I have the following table layout in a habtm relationship: ------------ ----------------------- -------------- | products | ----| categories_products |-----| categories | ------------ ----------------------- -------------- What would be the best way to pull out all the products for a given category? At the moment, i''ve got it going by specifing a join manually in the find() but that just doesn''t seem groovey enough...
2006 Jul 27
1
importing data with migration for habtm
I have 2 tables: products and categories. They are both linked by a habtm association. I have a fixture to import all the data in each table but I dont know how to import the data in the categories_products table since that table has no model, so I cant use that code: f = Fixtures.new(Category.connection, # a database connection "categories", # table name Category, # model class File.join(File.dirname(__FILE__), "dev...
2006 Jun 14
3
Prevent duplicate HABTM associations
Hi, I am trying to restrict duplicate has_and_belongs_to_many associations. I tried to find support for a association validation for duplicates but couldn''t find anything. I understand I could use :uniq=>true on the model association but this would only prevent it from displaying duplicates, I want to stop duplicate associations being inserted in the first place. I have a vague
2005 Aug 15
0
RE: has_many_belongs_to_many insert issues [CLOSED]
...ny_belongs_to_many insert issues Hi, I have an hmbtm relationship setup like: class Catogory < ActiveRecord::Base has_many_belongs_to_many: products end class Product < ActiveRecord::Base has_many_belongs_to_many: categories end With the usual SQL tables (i.e., categories, products, categories_products). NOTE: I AM USING MICROSOFT SQL SERVER -- that might be the source of my issues... All my ids are int identity(1, 1) not null in SQL. I quit using uniqueidentifier as Rails gets very confused. I cannot add a Product<->Category relationship via Rails, like: aProduct = Product.find(41234)...
2006 May 03
3
Sorting by multiple categories
I have a database with a field called ''category''. ''category'' contains the categories separated by a "," i.e. 1, 2, 5 I know with something like: @products = Product.find(:all, :condition => "category = ''1''") I could get some results if any of the ''category'' fields only contained "1" but