From 1f9d234a6b567e68d97e71da6f19bd126e7f7058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 17 Oct 2009 15:56:44 -0300 Subject: By default use ActiveModel API in controller generators, unless otherwise specified [#3123 status:resolved] --- railties/lib/rails/generators/resource_helpers.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'railties/lib/rails/generators/resource_helpers.rb') diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index d4b0d4b945..0385581083 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -1,3 +1,5 @@ +require 'rails/generators/active_model' + module Rails module Generators # Deal with controller names on scaffold and add some helpers to deal with @@ -47,20 +49,11 @@ module Rails raise "You need to have :orm as class option to invoke orm_class and orm_instance" end - active_model = "#{options[:orm].to_s.classify}::Generators::ActiveModel" - - # If the orm was not loaded, try to load it at "generators/orm", - # for example "generators/active_record" or "generators/sequel". begin - klass = active_model.constantize - rescue NameError - require "rails/generators/#{options[:orm]}" + "#{options[:orm].to_s.classify}::Generators::ActiveModel".constantize + rescue NameError => e + Rails::Generators::ActiveModel end - - # Try once again after loading the file with success. - klass ||= active_model.constantize - rescue Exception => e - raise Error, "Could not load #{active_model}, skipping controller. Error: #{e.message}." end end -- cgit v1.2.3