polymorphic-associations
What is the best practice to get the same behavior from multiple AR objects that are referred to polymorphically?
This is a Rails开发者_开发知识库 3 application. I have images that can be tied to either a Product or a Brand.A product has an identifier and a Brand has a name.[详细]
2023-01-30 02:12 分类:问答Rails + Thinking-Sphinx polymorphic association
class User < ActiveRecord::Base has_many :followings, :as => :followable, :dependent => :destroy, :class_name => \'Follow\'[详细]
2023-01-26 23:45 分类:问答PHP & Mysql - Left Outer Join between two tables
I have two tables called \'events\' and \'topics\' each table can have many comments. What I need to do is list all the events and topics with the amount of comments for each row. I\'ve managed to re[详细]
2023-01-26 23:26 分类:问答Find your way up the polymorphic tree to one parent
I have a simple polymorphic association #comment.r开发者_JAVA百科b belongs_to :commentable, :polymorphic => true[详细]
2023-01-21 20:06 分类:问答Should I joint-index an ActiveRecord polymorphic association?
I have a metric table that I expect to be very large.It has a polymorphic association so that it can belongs_to other models that want to record some metric.I typically index association columns like[详细]
2023-01-21 05:29 分类:问答Model and controller design approach for polymorphic assocation
Below I have outlined the structure of a polymorphic association. In VacationsController I put some comments inline describing my current issue. However, I wanted to post this to see if my whole appro[详细]
2023-01-21 00:35 分类:问答Searching polymorphic associations in Rails
I have a need in my app to allow users to bookmark a post.They should only be able to create one bookmark per post.I\'ve set up my polymorphic association like so:[详细]
2023-01-20 17:31 分类:问答accepts_nested_attributes_for with belongs_to polymorphic
I would like set up a polymorphic relation with accepts_nested_attributes_for. Here is the code: class Contact <ActiveRecord::Base[详细]
2023-01-20 15:38 分类:问答Defining an object's behavior using polymorphic inheritance
Today I was faced with a challenge to create different behaviors for my shopping cart model. That\'s because the owner of the online shopping wanted to create some promotions like buy 1, get 5 or get[详细]
2023-01-20 05:17 分类:问答How to join across polymorphic tables in one query?
I have 2 polymorphic associations through which I need to query. I have a news_article table which has a polymorphic association to teams, play开发者_如何学Cers, etc. Those teams, players, etc have[详细]
2023-01-19 03:46 分类:问答