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
b77e1ae6
Commit
b77e1ae6
authored
May 15, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't require DB conncetion in AttrEncrypted.
parent
25b09688
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
config/initializers/attr_encrypted_no_db_connection.rb
config/initializers/attr_encrypted_no_db_connection.rb
+29
-0
No files found.
config/initializers/attr_encrypted_no_db_connection.rb
0 → 100644
View file @
b77e1ae6
module
AttrEncrypted
module
Adapters
module
ActiveRecord
protected
def
attribute_instance_methods_as_symbols
# We add accessor methods of the db columns to the list of instance
# methods returned to let ActiveRecord define the accessor methods
# for the db columns
if
connection_established?
&&
table_exists?
columns_hash
.
keys
.
inject
(
super
)
{
|
instance_methods
,
column_name
|
instance_methods
.
concat
[
column_name
.
to_sym
,
:"
#{
column_name
}
="
]}
else
super
end
end
def
connection_established?
begin
# use with_connection so the connection doesn't stay pinned to the thread.
ActiveRecord
::
Base
.
connection_pool
.
with_connection
{
ActiveRecord
::
Base
.
connection
.
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