Merge pull request #52616 from byroot/fix-console-app-name

rails console: Handle non standard application names
This commit is contained in:
Jean Boussier 2024-08-15 16:49:15 +02:00 committed by GitHub
commit 3dbff874b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -135,6 +135,13 @@ module Rails
@initialized
end
# Returns the dhasherized application name.
#
# MyApp::Application.new.name => "my-app"
def name
self.class.name.underscore.dasherize.delete_suffix("/application")
end
def run_load_hooks! # :nodoc:
return self if @ran_load_hooks
@ran_load_hooks = true

View File

@ -89,9 +89,8 @@ module Rails
end
env = colorized_env
app_name = @app.class.module_parent_name.underscore.dasherize
prompt_prefix = "%N(#{env})"
IRB.conf[:IRB_NAME] = app_name
IRB.conf[:IRB_NAME] = @app.name
IRB.conf[:PROMPT][:RAILS_PROMPT] = {
PROMPT_I: "#{prompt_prefix}> ",