Skip to content

Commit 55addc7

Browse files
committed
Use Thor for built-in secret task
Currently we use both Thor and Rake for `bin/rails` commands. We eventually want to get all the built-ins task promoted to Thor Commands. This migrates the secret task to Thor.
1 parent 779c14b commit 55addc7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
module Rails
4+
module Command
5+
class SecretCommand < Base # :nodoc:
6+
desc "secret", "Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)."
7+
def perform
8+
require "securerandom"
9+
puts SecureRandom.hex(64)
10+
end
11+
end
12+
end
13+
end

railties/lib/rails/tasks/misc.rake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# frozen_string_literal: true
22

3-
desc "Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)."
4-
task :secret do
5-
require "securerandom"
6-
puts SecureRandom.hex(64)
7-
end
8-
93
desc "List versions of all Rails frameworks and the environment"
104
task about: :environment do
115
puts Rails::Info

0 commit comments

Comments
 (0)