Skip to content

Have ActiveRecord automagically build an association when accessed. Useful for belongs_to associations which should never be nil.

Notifications You must be signed in to change notification settings

ajrkerr/build_associated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A very simple gem. This allows you to use the following code in ActiveRecord.

class PlanSku < ActiveRecord::Base
	belongs_to :sku
	belongs_to :plan_cost
	belogns_to :plan_coverage

	build_associated :sku
	build_associated :plan_cost
	build_associated :plan_coverage
end

plan = PlanSku.new
plan.sku # Instead of nil, it now returns PlanSku.build_sku

Tested on Rails3.1. Use at own risk.

About

Have ActiveRecord automagically build an association when accessed. Useful for belongs_to associations which should never be nil.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages