search for: polymorp

Displaying 4 results from an estimated 4 matches for "polymorp".

Did you mean: polymorf
2006 Sep 03
7
using polymorphic associations with acts_as_list
This is what I have class Photo < ActiveRecord::Base belongs_to :image, :polymorphic => true acts_as_list :scope => image end class Place < ActiveRecord::Base has_many :photos, :as => :image end class Child < ActiveRecord::Base has_many :photos, :as => :image end I want to be able to reorder the images. What I need is for the position of the photos...
2006 May 20
7
Polymorphic, many-to-many, self-referential data model
...I''ve been unable to work how to get this to work with the cool ActiveRecord helpers. I''m not sure if it''s possible, Josh Susser''s blog suggests it is, but damned if I can work it out... I have: Container which can contain one or more Element. An Element is a polymorph of either a Container or a Chunk. An Element can exist in one or more Containers. I use a table called ownerships as the join between Containers and Element. Here''s some code: create_table :containers do |t| t.column :name, :string end create_table :chunks do |t| t.colu...
2006 Aug 16
0
Polymorphic Associations and grouping users and projects
...ips end class Membership < ActiveRecord::Base belongs_to :group belongs_to :user end class Group < ActiveRecord::Base has_many :memberships has_many :users, :through => :memberships end What I would like to do is add project groupings to the admin and I think I may need to use polymorpic associations. However I dont know if this is he best option. For someone who is much brighter than me, is the code below the best way to achieve this? class User < ActiveRecord::Base has_many :memberships, :as => :groupabale has_many :groups, :through => :memberships end cl...
2006 Jun 06
1
Please Help with single table inheritance relationships
I''ve been searching the web, wikis, and more, and I haven''t turned up examples of how to have multiple entities in a single-table inheritance related to anything. I have an addresses table, but multiple entities can have Addresses: both Person (which has 2 addresses) and Retailer. I''ve been told that I need to use single-table inheritance, and this was my attempt: