aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/api/task.rb12
-rw-r--r--railties/lib/rails/app_rails_loader.rb2
-rw-r--r--railties/lib/rails/engine.rb9
-rw-r--r--railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb6
-rw-r--r--railties/lib/rails/generators/rails/controller/controller_generator.rb36
-rw-r--r--railties/lib/rails/source_annotation_extractor.rb2
6 files changed, 49 insertions, 18 deletions
diff --git a/railties/lib/rails/api/task.rb b/railties/lib/rails/api/task.rb
index 3e32576040..1f9568fb5f 100644
--- a/railties/lib/rails/api/task.rb
+++ b/railties/lib/rails/api/task.rb
@@ -16,7 +16,8 @@ module Rails
:include => %w(
README.rdoc
lib/active_record/**/*.rb
- )
+ ),
+ :exclude => 'lib/active_record/vendor/*'
},
'activemodel' => {
@@ -32,22 +33,23 @@ module Rails
lib/abstract_controller/**/*.rb
lib/action_controller/**/*.rb
lib/action_dispatch/**/*.rb
- )
+ ),
+ :exclude => 'lib/action_controller/vendor/*'
},
'actionview' => {
:include => %w(
README.rdoc
lib/action_view/**/*.rb
- ),
- :exclude => 'lib/action_view/vendor/*'
+ )
},
'actionmailer' => {
:include => %w(
README.rdoc
lib/action_mailer/**/*.rb
- )
+ ),
+ :exclude => 'lib/action_mailer/vendor/*'
},
'railties' => {
diff --git a/railties/lib/rails/app_rails_loader.rb b/railties/lib/rails/app_rails_loader.rb
index fbb83fa10e..4a17803f1c 100644
--- a/railties/lib/rails/app_rails_loader.rb
+++ b/railties/lib/rails/app_rails_loader.rb
@@ -2,7 +2,7 @@ require 'pathname'
module Rails
module AppRailsLoader
- RUBY = Gem.ruby
+ RUBY = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"]
EXECUTABLES = ['bin/rails', 'script/rails']
BUNDLER_WARNING = <<EOS
Looks like your app's ./bin/rails is a stub that was generated by Bundler.
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index be8af5c46c..8000fc3b1e 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -351,13 +351,8 @@ module Rails
Rails::Railtie::Configuration.eager_load_namespaces << base
base.called_from = begin
- call_stack = if Kernel.respond_to?(:caller_locations)
- caller_locations.map(&:path)
- else
- # Remove the line number from backtraces making sure we don't leave anything behind
- caller.map { |p| p.sub(/:\d+.*/, '') }
- end
-
+ # Remove the line number from backtraces making sure we don't leave anything behind
+ call_stack = caller.map { |p| p.sub(/:\d+.*/, '') }
File.dirname(call_stack.detect { |p| p !~ %r[railties[\w.-]*/lib/rails|rack[\w.-]*/lib/rack] })
end
end
diff --git a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb
index 4a40ba654d..69c10efa47 100644
--- a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb
+++ b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb
@@ -21,13 +21,13 @@
<%%= f.label :password_confirmation %><br>
<%%= f.password_field :password_confirmation %>
<% else -%>
- <% if attribute.reference? -%>
+ <%- if attribute.reference? -%>
<%%= f.label :<%= attribute.column_name %> %><br>
<%%= f.<%= attribute.field_type %> :<%= attribute.column_name %> %>
- <% else -%>
+ <%- else -%>
<%%= f.label :<%= attribute.name %> %><br>
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
- <% end -%>
+ <%- end -%>
<% end -%>
</div>
<% end -%>
diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb
index bae54623c6..822f35fb42 100644
--- a/railties/lib/rails/generators/rails/controller/controller_generator.rb
+++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb
@@ -10,11 +10,45 @@ module Rails
def add_routes
actions.reverse.each do |action|
- route %{get "#{file_name}/#{action}"}
+ route generate_routing_code(action)
end
end
hook_for :template_engine, :test_framework, :helper, :assets
+
+ private
+
+ # This method creates nested route entry for namespaced resources.
+ # For eg. rails g controller foo/bar/baz index
+ # Will generate -
+ # namespace :foo do
+ # namespace :bar do
+ # get "baz/index"
+ # end
+ # end
+ def generate_routing_code(action)
+ depth = class_path.length
+ # Create 'namespace' ladder
+ # namespace :foo do
+ # namespace :bar do
+ namespace_ladder = class_path.each_with_index.map do |ns, i|
+ %{#{" " * i * 2}namespace :#{ns} do\n }
+ end.join
+
+ # Create route
+ # get "baz/index"
+ route = %{#{" " * depth * 2}get "#{file_name}/#{action}"\n}
+
+ # Create `end` ladder
+ # end
+ # end
+ end_ladder = (1..depth).reverse_each.map do |i|
+ "#{" " * i * 2}end\n"
+ end.join
+
+ # Combine the 3 parts to generate complete route entry
+ namespace_ladder + route + end_ladder
+ end
end
end
end
diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb
index 290634290f..b806b922b7 100644
--- a/railties/lib/rails/source_annotation_extractor.rb
+++ b/railties/lib/rails/source_annotation_extractor.rb
@@ -82,7 +82,7 @@ class SourceAnnotationExtractor
case item
when /\.(builder|rb|coffee|rake)$/
/#\s*(#{tag}):?\s*(.*)$/
- when /\.(css|scss|sass|js)$/
+ when /\.(css|scss|sass|less|js)$/
/\/\/\s*(#{tag}):?\s*(.*)$/
when /\.erb$/
/<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/