Prelang / feedback

8 stars 0 forks source link

Polymorphic relations #4

Open wdiechmann opened 10 years ago

wdiechmann commented 10 years ago

3 a pattern (if you like) that I use quite often is the polymorphic association (-able) like in the attached screen dump - I don’t know how it might fly but it sure would be nice to add a polymorphic capability to a table by switching a knob like scaffold and friends

use case might go like this: as a User I need a model to connect Url to Person, Contact, Order and Call so I add a Urlable model, and when the model name input is blurred prelang ’sees’ the able suffix to the model and suggests “on” in the polymorphic checkbox and adds a belongs_to Url relation and adds a polymorphic Urlable relation and going forward allow me to tick off urlable (like the scaffold knob) on models and when being generated prelang adds urlable_type string and urlable_id integer fields to urlables table and adds belongs_to: :url and has_many :urlables, polymorphic: true to Urlable model and adds “has_many :urls, through: :urlable” on models with the urlable checkbox

yordis commented 10 years ago

:+1:

betoharres commented 9 years ago

+1

rush-skills commented 9 years ago

+1

stanrails commented 7 years ago

+1