Delegate does not create setter methods

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the rails category.

Last Updated: 2024-04-25

Delegate does not create setter methods

I had the following code in a model:

delegate :email, :password, :password_confirmation, to: :user

I assumed and wrote code under this assumption that I could do obj.user.email = x

This wasn't the case.

Lessons

Do not assume because you get getter methods you also get setter methods.