-
-
Save lucasprag/a6f1fb4f3155b5423bba to your computer and use it in GitHub Desktop.
Revisions
-
gullitmiranda revised this gist
Apr 28, 2015 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,10 +8,11 @@ rescue URI::InvalidURIError raise "Invalid DATABASE_URL" end env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] raise "No RACK_ENV or RAILS_ENV found" unless env def attribute(name, value, force_string = false) if value value_string = @@ -43,7 +44,7 @@ adapter = case uri.scheme.to_s end %> <%= env %>: <%= attribute "adapter", adapter %> <%= attribute "database", database %> <%= attribute "username", username %> @@ -53,4 +54,4 @@ adapter = case uri.scheme.to_s <% params.each do |key, value| %> <%= key %>: <%= value.first %> <% end %> -
gullitmiranda revised this gist
Apr 28, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,8 @@ end raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"] env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] def attribute(name, value, force_string = false) if value value_string = @@ -24,7 +26,7 @@ def attribute(name, value, force_string = false) end end database = "#{(uri.path || "").split("/")[1]}_#{env}" username = uri.user password = uri.password host = uri.host -
gullitmiranda revised this gist
Apr 27, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def attribute(name, value, force_string = false) end end database = "#{(uri.path || "").split("/")[1]}_#{ENV['RAILS_ENV']}" username = uri.user password = uri.password host = uri.host -
gullitmiranda revised this gist
Apr 27, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def attribute(name, value, force_string = false) end end database = "#{(uri.path || "").split("/")[1]}_#{RAILS_ENV}" username = uri.user password = uri.password host = uri.host -
gullitmiranda created this gist
Nov 18, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ <% require 'cgi' require 'uri' begin uri = URI.parse(ENV["DATABASE_URL"]) rescue URI::InvalidURIError raise "Invalid DATABASE_URL" end raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"] def attribute(name, value, force_string = false) if value value_string = if force_string '"' + value + '"' else value end "#{name}: #{value_string}" else "" end end database = (uri.path || "").split("/")[1] username = uri.user password = uri.password host = uri.host port = uri.port params = CGI.parse(uri.query || "") params["encoding"] = ["utf8"] unless params["encoding"].present? params["pool" ] = [5] unless params["pool" ].present? adapter = case uri.scheme.to_s when "postgres" then "postgresql" when "mysql" then "mysql2" else uri.scheme.to_s end %> <%= ENV["RAILS_ENV"] || ENV["RACK_ENV"] %>: <%= attribute "adapter", adapter %> <%= attribute "database", database %> <%= attribute "username", username %> <%= attribute "password", password, true %> <%= attribute "host", host %> <%= attribute "port", port %> <% params.each do |key, value| %> <%= key %>: <%= value.first %> <% end %>