waymondo / turboboost

Enhanced AJAX handling for Rails apps
166 stars 17 forks source link

Support the rails 4.2 (4.2.0beta4 at time of commit) #4

Closed dimroc closed 10 years ago

dimroc commented 10 years ago

Rails >= 4.2 has changed the method arity of _compute_redirect_to_location from (options) to (*args). The validation inside then expects two parameters: request, options. This commit handles these changes.

Rails 4.2 _compute_redirect_to_location source

Instead of checking the Rails.version, we could check the method arity:

if method(: _compute_redirect_to_location).arity == -1
  self.location = _compute_redirect_to_location(request, options)
else ...

I was torn, but went with the version check because it was simpler.

waymondo commented 10 years ago

Thanks for this. I wasn't familiar with .arity which is a handy thing to be aware of. I can see how the arity checking might be stronger, but I think checking Rails.version is fine for the sake of simplicity for the time being.

dimroc commented 10 years ago

Hi @waymondo , could we push a new version of the gem with this fix?

waymondo commented 10 years ago

Sure, just pushed a new version to rubygems.