Sha256: aa6ca6bfbb19db5d4a8477f4bd5e77d34bd1436c7518540ab5dbc03aa0c77dd3
Contents?: true
Size: 898 Bytes
Versions: 1
Compression:
Stored size: 898 Bytes
Contents
require 'rails/generators/generated_attribute' module GeneratorUtils RAILS_ADDED_COLS = %w(id created_at updated_at) #TODO...There has GOT to be a better way to do this (column name gets listed first if it contains the word "name") ATTR_SORT_PROC = proc do |a, b| if a =~ /name/ 1 elsif b =~ /name/ -1 elsif a =~ /email/ 1 elsif b =~ /email/ -1 else 0 end end def self.attr_cols(table_name) #return an array of the columns we are interested in allowing the user to change... # as GeneratedAttribute objects acs = table_name.classify.constantize.columns .reject{ |col| RAILS_ADDED_COLS.include?(col.name) } .sort(&ATTR_SORT_PROC) .map { |ac| Rails::Generators::GeneratedAttribute.new(ac.name, ac.type)} end def self.curr_locale I18n.locale.to_s end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
controller_scaffolding-1.4.4 | lib/generators/generator_utils.rb |