Skip to content

Comment on Friendly attributes pattern in Rubyparent

Comments

i find this structure a bit odd. i would have gone for the following pattern:

    Billing::Plan.find_or_create_all_by_attrs!(
      standard => {1.month: 10, 1.year: 100},
      pro => {1.month: 50, 1.year: 500},
      enterprise => {1.month: 100, 1.year: 1000}
    )

This is supported and would work with no implementation changes. The "Friendly Attributes" idea is very flexible.

Just a small Ruby syntax correction for your example:

  Billing::Plan.find_or_create_all_by_attrs!(
    standard: {1.month => 10, 1.year => 100},
    ...
  )
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.