Posts Tagged ‘best-practices’

“new” actions in nested rails resources

def new
@my_model = MyModel.new
end

# vs.

def new
@my_model = @my_parent_model.my_models.build
# gives you access to parent properties
# (useful e.g. in views)
end

CUDdly design (as coined by Pivotal Labs)

Pivotal Labs coin the term CUDdly Models for refactoring public model actions with side effects, into proper ActiveRecord callbacks, thus leveraging the power of encapsulation, transactions, consistent interface, and (activerecord) lifecycle power.

See this for a more thorough explanation.

beautiful code (Marcel Molina at rubyhoedown2007)

Apply these principles to software development not because they necessarily define beauty, but they definitely define something good!

  • PROPORTION
  • INTEGRITY
  • CLARITY

Taken from