Skip to content

Commit 3dbff87

Browse files
authored
Merge pull request rails#52616 from byroot/fix-console-app-name
rails console: Handle non standard application names
2 parents 41921f9 + 1099b81 commit 3dbff87

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

railties/lib/rails/application.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ def initialized?
135135
@initialized
136136
end
137137

138+
# Returns the dhasherized application name.
139+
#
140+
# MyApp::Application.new.name => "my-app"
141+
def name
142+
self.class.name.underscore.dasherize.delete_suffix("/application")
143+
end
144+
138145
def run_load_hooks! # :nodoc:
139146
return self if @ran_load_hooks
140147
@ran_load_hooks = true

railties/lib/rails/commands/console/irb_console.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ def start
8989
end
9090

9191
env = colorized_env
92-
app_name = @app.class.module_parent_name.underscore.dasherize
9392
prompt_prefix = "%N(#{env})"
94-
IRB.conf[:IRB_NAME] = app_name
93+
IRB.conf[:IRB_NAME] = @app.name
9594

9695
IRB.conf[:PROMPT][:RAILS_PROMPT] = {
9796
PROMPT_I: "#{prompt_prefix}> ",

0 commit comments

Comments
 (0)