You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bbenezech edited this page Nov 29, 2011
·
5 revisions
Synopsys:
classPlayer < ActiveRecord::Basehas_one:draft,:dependent=>:destroy,:inverse_of=>:player# for nested fields: (natural choice for a has_one association)attr_accessible:draft_attributesaccepts_nested_attributes_for:draft,:allow_destroy=>true# or if you want a dropdown select: attr_accessible:draft_id# Since ActiveRecord does not create setters/getters for has_one associations (why is beyond me), diy:defdraft_idself.draft.try:idenddefdraft_id=(id)self.draft=Draft.find_by_id(id)endend# for infoclassDraft < ActiveRecord::Basebelongs_to:player,:inverse_of=>:draftendRailsAdmin.config |config| doconfig.modelPlayerdoconfigure:draftdo# configuration hereendendend