Fail with private setter by cvb

class TestModel < ActiveRecord::Base

private

  def test_attr=(v)
    write_attribute(:test_attr, v)
  end
end

#ruby

and when try to build you will get pretty cryptic error

ActiveRecord::UnknownAttributeError: unknown attribute: test_attr

Similar posts

Comments

releu commented about 1 year ago

757fb0d5ec7560b6f25f5bd98eadc020?size=52

What do you expect?

makaroni4 commented about 1 year ago

E302c3320cd14b02cbe237b479d7f884?size=52

Haha, this is a story about "God damn how could I miss that?"

cvb commented about 1 year ago

45ae4438d56d8492f842d2d395ca8abe?size=52

I expected more human error, like "Man it's private, wtf?!"

cvb
makaroni4
releu