Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
61ceb450
Commit
61ceb450
authored
May 15, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix.
parent
ba07c9f7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
13 deletions
+5
-13
config/initializers/attr_encrypted_no_db_connection.rb
config/initializers/attr_encrypted_no_db_connection.rb
+5
-13
No files found.
config/initializers/attr_encrypted_no_db_connection.rb
View file @
61ceb450
...
...
@@ -2,27 +2,19 @@ module AttrEncrypted
module
Adapters
module
ActiveRecord
def
attribute_instance_methods_as_symbols_with_no_db_connection
if
connection_established?
# Use with_connection so the connection doesn't stay pinned to the thread.
connected
=
::
ActiveRecord
::
Base
.
connection_pool
.
with_connection
(
&
:active?
)
rescue
false
if
connected
# Call version from AttrEncrypted::Adapters::ActiveRecord
attribute_instance_methods_as_symbols_without_no_db_connection
else
# Call version from AttrEncrypted
(`super` with regards to AttrEncrypted::Adapters::ActiveRecord)
# Call version from AttrEncrypted
, i.e., `super` with regards to AttrEncrypted::Adapters::ActiveRecord
AttrEncrypted
.
instance_method
(
:attribute_instance_methods_as_symbols
).
bind
(
self
).
call
end
end
alias_method_chain
:attribute_instance_methods_as_symbols
,
:no_db_connection
private
def
connection_established?
begin
# Use with_connection so the connection doesn't stay pinned to the thread.
ActiveRecord
::
Base
.
connection_pool
.
with_connection
{
|
con
|
con
.
active?
}
rescue
Exception
false
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment