Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove deprecation warnings for rails 6
In rails 6 there is deprecation warning for `update_attributes!` method. It will be replaced with `update!` method. In order to remove deprecation I have wrapped method call inside `rails_api` facade.
- Loading branch information
Showing
6 changed files
with
48 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActsAsMessageable | ||
class Rails6 | ||
def initialize(subject) | ||
@subject = subject | ||
end | ||
|
||
def attr_accessible(*); end | ||
|
||
def default_scope(order_by) | ||
@subject.send(:default_scope) { order(order_by) } | ||
end | ||
|
||
def scoped | ||
@subject.scope | ||
end | ||
|
||
def update_attributes!(*args) | ||
@subject.update!(*args) | ||
end | ||
|
||
def method_missing(name, *args) | ||
@subject.send(name, *args) || super | ||
end | ||
|
||
def respond_to_missing?(method_name, include_private = false) | ||
%w[attr_accessible default_scope scoped update_attributes!].include?(method_name) || super | ||
end | ||
end | ||
end |