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

rails 4.1 deprecates Validator#setup #114

Closed
wants to merge 1 commit into from
Closed

Conversation

razum2um
Copy link

looks some kind of ugly, but i'd rather not to bump version because of this change

# DEPRECATION WARNING: The `Validator#setup` instance method is deprecated
and will be removed on Rails 4.2.

@jaredbeck
Copy link

looks some kind of ugly

Yeah, the alias_method seems like a bit of a hack.

However, I've tried out this patch in my own project, and can confirm that the deprecation warnings are gone, and all my tests still pass. Hope that helps.

gem 'validates_timeliness',
  github: 'razum2um/validates_timeliness',
  ref: 'b195081f6aeead619430ad38b0f0dfe4d4981252'

cc: @adzap

@razum2um razum2um changed the title rails 4.2 compatible rails 4.1 deprecates Validator#setup Mar 26, 2014
@jaredbeck
Copy link

Here's another solution from @yabawock.

@razum2um
Copy link
Author

razum2um commented Apr 7, 2014

yes, it's better to rely on respond_to? :deprecated_setup than on a version
please, prefer his solution

@razum2um razum2um closed this Apr 7, 2014
@jaredbeck
Copy link

Hmm I'm not sure you should close this, unless there's another PR I'm not
seeing.

On Monday, April 7, 2014, Vlad Bokov notifications@github.com wrote:

Closed #114 #114.

Reply to this email directly or view it on GitHubhttps://github.com//pull/114
.

Jared Beck * (607) 216-5373 * jared@jaredbeck.com

@johncarney
Copy link

Actually, respond_to? :deprecated_setup is no good. First because deprecated_setup is a private instance method, so ActiveModel::Validator.respond_to? :deprecated_setup will always return false.

Replacing it with private_instance_methods.include? :deprecated_setup works, but then you have a small problem of what happens when deprecated_setup is removed altogether in Rails 4.2. You'll end up with a redundant method definition (or alias). This probably isn't too bad and you can mitigate the risk of future conflict by adding method_defined? :setup to the conditional.

I've sent a pull request with this solution: #117

@felixbuenemann
Copy link

I've yet another approach to this using version detection: felixbuenemann/validates_timeliness@b04193d

@johncarney
Copy link

I prefer a method based on actual behaviour rather than version numbers, but I do like the way you've put it in a constant.

@felixbuenemann
Copy link

I think your version is fine for this case.

@jaredbeck
Copy link

👍 @felixbuenemann I like the constant too. Let's move this conversation over to #117 since this PR is closed.

issyl0 pushed a commit to alphagov/support that referenced this pull request Mar 27, 2015
- A few things here that took some figuring out, hence not putting it
  into the first commit:
  - The `validates_timeliness` gem (used for `validate_date` in models
    here) uses the now deprecated `Validator#setup` method within it,
    according to adzap/validates_timeliness#113
    and adzap/validates_timeliness#114. This
    gem seems not to be actively maintained anymore, at least at the
    point of those PRs, so someone forked it and fixed the issues,
    releasing version 3.1.1 of jc-validates_timeliness. In order for
    these deprecation warnings to not flood the test output, I
    switched this app to use the new gem.
issyl0 pushed a commit to alphagov/support that referenced this pull request Mar 27, 2015
- A few things here that took some figuring out, hence not putting it
  into the first commit:
  - The `validates_timeliness` gem (used for `validate_date` in models
    here) uses the now deprecated `Validator#setup` method within it,
    according to adzap/validates_timeliness#113
    and adzap/validates_timeliness#114. This
    gem seems not to be actively maintained anymore, at least at the
    point of those PRs, so someone forked it and fixed the issues,
    releasing version 3.1.1 of jc-validates_timeliness. In order for
    these deprecation warnings to not flood the test output, I
    switched this app to use the new gem.
issyl0 pushed a commit to alphagov/support that referenced this pull request Mar 31, 2015
- A few things here that took some figuring out, hence not putting it
  into the first commit:
  - The `validates_timeliness` gem (used for `validate_date` in models
    here) uses the now deprecated `Validator#setup` method within it,
    according to adzap/validates_timeliness#113
    and adzap/validates_timeliness#114. This
    gem seems not to be actively maintained anymore, at least at the
    point of those PRs, so someone forked it and fixed the issues,
    releasing version 3.1.1 of jc-validates_timeliness. In order for
    these deprecation warnings to not flood the test output, I
    switched this app to use the new gem.
issyl0 pushed a commit to alphagov/support that referenced this pull request Apr 2, 2015
- A few things here that took some figuring out, hence not putting it
  into the first commit:
  - The `validates_timeliness` gem (used for `validate_date` in models
    here) uses the now deprecated `Validator#setup` method within it,
    according to adzap/validates_timeliness#113
    and adzap/validates_timeliness#114. This
    gem seems not to be actively maintained anymore, at least at the
    point of those PRs, so someone forked it and fixed the issues,
    releasing version 3.1.1 of jc-validates_timeliness. In order for
    these deprecation warnings to not flood the test output, I
    switched this app to use the new gem.
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.

None yet

4 participants