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

Change errors and metadata accessor methods #101

Merged
merged 1 commit into from
Apr 18, 2013
Merged

Conversation

remi
Copy link
Owner

@remi remi commented Apr 18, 2013

This adds support for store_errors and store_metadata, based on this comment thread started by @pencil.

Basically, it allows us to do this:

class User
  include Her::Model

  store_errors :errors # default is :response_errors
  store_metadata :my_data # default is :metadata
end

and override the errors method provided by ActiveModel::Validations and make it returns the value of @response_errors, which is the errors returned by the API.

@calmyournerves
Copy link
Contributor

👍 :shipit:

@pencil
Copy link
Collaborator

pencil commented Apr 18, 2013

👍 :shipit:

remi added a commit that referenced this pull request Apr 18, 2013
Change errors and metadata accessor methods
@remi remi merged commit 734ad7e into master Apr 18, 2013
@remi remi deleted the store-errors-and-metadata branch April 18, 2013 14:32
@remi
Copy link
Owner Author

remi commented Apr 18, 2013

Actually, I think I’m gonna change store_errors to store_response_errors, which makes more sense, since we’re overriding the response_errors accessor, not errors.

@aaronmcadam
Copy link

Setting store_response_errors :errors makes calling .valid? on a model object raise:

NoMethodError: undefined method `add_on_blank' for {}:Hash from ~/.rvm/gems/ruby-2.0.0-p195@global/gems/activemodel-3.2.13/lib/active_model/validations/presence.rb:8:in `validate'

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.

4 participants