Rails Has Two and With Many -


i'm working on rails 4 app there model called apps. each app can have multiple certificates stored in certificates model. out of certificates each app can have development , production certificate active current app. @ single given time 2 certificates (development/production) can active app. i'm trying come activerecord structure logic i'm lost. suggestions on this?

apps (has many certificates)   - development_certificate   - production_certificate  certificates (belongs app) 

the solution more closely models data 2 one-to-one relationships:

class app < activerecord::base   belongs_to :production_certificate, class_name: "certificate"   belongs_to :development_certificate, class_name: "certificate" end 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

visual studio - TFS will not accept changes I've made to a Java project -