module Rails::Generators::ResourceHelpers
Deal with controller names on scaffold and add some helpers to deal with ActiveModel.
Attributes
controller_name[R]
Protected Instance Methods
controller_class_name()
click to toggle source
# File lib/rails/generators/resource_helpers.rb, line 48 def controller_class_name (controller_class_path + [controller_file_name]).map!{ |m| m.camelize }.join('::') end
controller_class_path()
click to toggle source
# File lib/rails/generators/resource_helpers.rb, line 36 def controller_class_path class_path end
controller_file_name()
click to toggle source
# File lib/rails/generators/resource_helpers.rb, line 40 def controller_file_name @controller_file_name ||= file_name.pluralize end
controller_file_path()
click to toggle source
# File lib/rails/generators/resource_helpers.rb, line 44 def controller_file_path @controller_file_path ||= (controller_class_path + [controller_file_name]).join('/') end
controller_i18n_scope()
click to toggle source
# File lib/rails/generators/resource_helpers.rb, line 52 def controller_i18n_scope @controller_i18n_scope ||= controller_file_path.gsub('/', '.') end
orm_class()
click to toggle source
Loads the ORM::Generators::ActiveModel class. This class is responsible to tell scaffold entities how to generate an specific method for the ORM. Check Rails::Generators::ActiveModel for more information.
# File lib/rails/generators/resource_helpers.rb, line 59 def orm_class @orm_class ||= begin # Raise an error if the class_option :orm was not defined. unless self.class.class_options[:orm] raise "You need to have :orm as class option to invoke orm_class and orm_instance" end begin "#{options[:orm].to_s.camelize}::Generators::ActiveModel".constantize rescue NameError Rails::Generators::ActiveModel end end end
orm_instance(name=singular_table_name)
click to toggle source
Initialize ORM::Generators::ActiveModel to access instance methods.
# File lib/rails/generators/resource_helpers.rb, line 75 def orm_instance(name=singular_table_name) @orm_instance ||= orm_class.new(name) end