has_many   219

« earlier    

Reverse polymorphic associations in Rails
To add fields that are common to all polymorphic models, add fields to the join model.

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media
rails  activerecord  polymorphic  has_many  data-model  database 
august 2016 by hellsten

« earlier    

related tags

"has_many  :collection  :has_many  :through  acceptance  accepts  accepts_nested_attributes  accepts_nested_attributes_for  active  activerec  activerecord  actrec  after_build  api  as  assoc  associated  association  associations  attributes  authors  bdd  belong  belongs_to  book  build  builder  callbacks  category  checkbox  cocoon  collection  complex  create  creating  custom  custom_route  data-model  database  db  delicious  dev  development  doc  ecto  elixir  excellent  extend  extension  factories  factory_girl  factorygirl  field_for  filter  form  form_for  forms  git  good  great  guide  habtm  has  has_many_through  has_on  has_one  hasmanythrough  hmt  howto  inheritance  join  joinmodel  jquery  machinist  manager  many  manytomany  map  mapping  migration  model  models  multiple  named  named_path  nested  new  objects  on  one  oop  orm  owner  phoenix  polymorphic  polymorphism  prefix  programming  queary  rail  rails  rails3  railscasts  rdoc  recommendations  record  records  reference  rel  relation  relational  relations  relationship  relationships  reportees  reputation  resource  resources  restful  ri  ror  ror3  route  routes  routing  rspec  ruby  rubyonrails  scala  scope  select  self-referential  self  selfreferencing  selfreferential  semantic  simpleform  socialnetworking  sql  stackoverflow  sti  subordinates  subtotal  sum  tdd  test  testing  through"  through  tips  total  touch  tutorial  tutorials  types  update_attribute  user  validation  web 

Copy this bookmark:



description:


tags: