Skip to content

Instantly share code, notes, and snippets.

@fractaledmind
Created May 14, 2024 16:14
Show Gist options
  • Save fractaledmind/5086a291e215a871275cb18c890b59a5 to your computer and use it in GitHub Desktop.
Save fractaledmind/5086a291e215a871275cb18c890b59a5 to your computer and use it in GitHub Desktop.
Example of simple file to centralize User management
users_file = Rails.root.join('storage', 'users.yml.erb')
if File.exist? users_file
users = YAML.load(ERB.new(File.read(users_file)).result)
User.insert_all(
users.map { |user| user.except("password") },
unique_by: :username
)
end
<%
def digest(username, password)
ActionController::HttpAuthentication::Digest.ha1(
{
username: username,
realm: Rails.application.credentials.auth_realm
},
password
)
end
%>
---
- username: spm
email: stephen@margheim.com
password: 'mypassword'
password_digest: <%= digest("spm", "mypassword") %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment