Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use values returned by attribute setter methods #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alextk
Copy link

@alextk alextk commented Aug 26, 2013

Hi Jeff,

I've discovered extremely annoying bug that is causing active record models to misbehave. If model defines setter methods that change values that are passed, the processed values are reverted back to original values (in new or build assoc methods) by your gem (all logic in setter method is discarded).
For example:

class User
  def email=(value)
    value = value.strip
    write_attribute(:email, value)
  end
end

u = User.new(:email => ' [email protected] ')
u.email  # will return ' [email protected] ', but should return '[email protected]'

Please accept one line fix pull request, which also contains rspec.

Regards,
Alex

@alextk
Copy link
Author

alextk commented Aug 27, 2013

Also, fixed that keys passed to initialize that aren't really activerecord attributes, will not be converted to attributes.

@kianw
Copy link

kianw commented Sep 29, 2013

+1

1 similar comment
@nchainani
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants