diff options
Diffstat (limited to 'railties/lib/rails/generators')
8 files changed, 32 insertions, 14 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 2c1742c6be..5838c9fc38 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -230,7 +230,7 @@ module Rails if defined?(JRUBY_VERSION) "gem 'therubyrhino'\n" else - "# gem 'therubyracer', platform: :ruby\n" + "# gem 'therubyracer', platforms: :ruby\n" end end diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 63703176de..b61a5fc69d 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -84,10 +84,11 @@ module Rails end def namespaced_class_path - @namespaced_class_path ||= begin - namespace_path = namespace.name.split("::").map {|m| m.underscore } - namespace_path + @class_path - end + @namespaced_class_path ||= [namespaced_path] + @class_path + end + + def namespaced_path + @namespaced_path ||= namespace.name.split("::").map {|m| m.underscore }[0] end def class_name @@ -134,7 +135,7 @@ module Rails end def route_url - @route_url ||= class_path.collect{|dname| "/" + dname }.join('') + "/" + plural_file_name + @route_url ||= class_path.collect {|dname| "/" + dname }.join + "/" + plural_file_name end # Tries to retrieve the application name or simple return application. diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt index 19cbf0e4f1..280f777cc0 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt @@ -9,8 +9,8 @@ ActiveSupport.on_load(:action_controller) do end <%- unless options.skip_active_record? -%> -# Disable root element in JSON by default. -ActiveSupport.on_load(:active_record) do - self.include_root_in_json = false -end +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end <%- end -%> diff --git a/railties/lib/rails/generators/rails/controller/templates/controller.rb b/railties/lib/rails/generators/rails/controller/templates/controller.rb index ece6bbba3b..633e0b3177 100644 --- a/railties/lib/rails/generators/rails/controller/templates/controller.rb +++ b/railties/lib/rails/generators/rails/controller/templates/controller.rb @@ -1,7 +1,7 @@ <% if namespaced? -%> -require_dependency "<%= namespaced_file_path %>/application_controller" -<% end -%> +require_dependency "<%= namespaced_path %>/application_controller" +<% end -%> <% module_namespacing do -%> class <%= class_name %>Controller < ApplicationController <% actions.each do |action| -%> diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec index 82ffeebb86..568ed653b7 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +++ b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec @@ -22,6 +22,8 @@ Gem::Specification.new do |s| <% if full? && !options[:skip_javascript] -%> # s.add_dependency "<%= "#{options[:javascript]}-rails" %>" <% end -%> +<% unless options[:skip_active_record] -%> s.add_development_dependency "<%= gem_for_database %>" +<% end -%> end diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Gemfile b/railties/lib/rails/generators/rails/plugin_new/templates/Gemfile index 9399c9cb77..7448b386c5 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/Gemfile +++ b/railties/lib/rails/generators/rails/plugin_new/templates/Gemfile @@ -1,17 +1,32 @@ source "http://rubygems.org" +<% if options[:skip_gemspec] -%> +<%= '# ' if options.dev? || options.edge? -%>gem "rails", "~> <%= Rails::VERSION::STRING %>" +<% if full? && !options[:skip_javascript] -%> +# gem "<%= "#{options[:javascript]}-rails" %>" +<% end -%> +<% else -%> # Declare your gem's dependencies in <%= name %>.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec +<% end -%> +<% unless options[:javascript] == 'jquery' -%> # jquery-rails is used by the dummy application gem "jquery-rails" +<% end -%> +<% if options[:skip_gemspec] -%> +group :development do + gem "<%= gem_for_database %>" +end +<% else -%> # Declare any dependencies that are still in development here instead of in # your gemspec. These might include edge Rails or gems from your path or # Git. Remember to move these dependencies to your gemspec before releasing # your gem to rubygems.org. +<% end -%> <% if options.dev? || options.edge? -%> # Your gem is dependent on dev or edge Rails. Once you can lock this diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile index 743036362e..1369140537 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile @@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -<% if full? && !options[:skip_active_record] -%> +<% if full? && !options[:skip_active_record] && !options[:skip_test_unit] -%> APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__) load 'rails/tasks/engine.rake' <% end %> diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb index 0294bde582..b3e74f9b02 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb @@ -1,7 +1,7 @@ <% if namespaced? -%> require_dependency "<%= namespaced_file_path %>/application_controller" -<% end -%> +<% end -%> <% module_namespacing do -%> class <%= controller_class_name %>Controller < ApplicationController # GET <%= route_url %> |