Navigation Menu

Skip to content

Commit

Permalink
Changed Rails.root to return a Pathname object (allows for Rails.root…
Browse files Browse the repository at this point in the history
….join("app", "controllers") => "#{RAILS_ROOT}/app/controllers") [#1482]
  • Loading branch information
dhh committed Nov 30, 2008
1 parent 668872e commit be140e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion railties/CHANGELOG
@@ -1,6 +1,6 @@
*2.3.0 [Edge]*

* Enhanced Rails.root to take parameters that'll be join with the root, like Rails.root('app', 'controllers') => File.join(Rails.root, 'app', 'controllers') #1482 [Damian Janowski]
* Changed Rails.root to return a Pathname object (allows for Rails.root.join('app', 'controllers') => "#{RAILS_ROOT}/app/controllers") #1482 [Damian Janowski/?]

* Added view path support for engines [DHH]

Expand Down
4 changes: 2 additions & 2 deletions railties/lib/initializer.rb
Expand Up @@ -48,8 +48,8 @@ def backtrace_cleaner
end
end

def root(*args)
File.join(RAILS_ROOT, *args.compact) if defined?(RAILS_ROOT)
def root
Pathname.new(RAILS_ROOT) if defined?(RAILS_ROOT)
end

def env
Expand Down
4 changes: 2 additions & 2 deletions railties/test/initializer_test.rb
Expand Up @@ -317,7 +317,7 @@ def test_rails_dot_root_equals_rails_root
assert_equal RAILS_ROOT, Rails.root
end

def test_rails_dot_root_accepts_arguments_for_file_dot_join
assert_equal File.join(RAILS_ROOT, 'app', 'controllers'), Rails.root('app', 'controllers')
def test_rails_dot_root_should_be_a_pathname
assert_equal File.join(RAILS_ROOT, 'app', 'controllers'), Rails.root.join('app', 'controllers')
end
end

1 comment on commit be140e8

@anildigital
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple change with more profit.

Please sign in to comment.