Module: Rails::Generators
- Defined in:
- lib/generators/controller/controller_scaffolding_generator.rb
Defined Under Namespace
Classes: ControllerScaffoldingGenerator
Constant Summary collapse
- RAILS_ADDED_COLS =
Generators module methods #####################
%w(id created_at updated_at)- ATTR_SORT_PROC =
TODO…There has GOT to be a better way to do this (column name gets listed first if it contains the word “name”)
proc do |a, b| if a =~ /name/ 1 elsif b =~ /name/ -1 elsif a =~ /email/ 1 elsif b =~ /email/ -1 else 0 end end
Class Method Summary collapse
Class Method Details
.attr_cols(table_name) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/generators/controller/controller_scaffolding_generator.rb', line 28 def 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| GeneratedAttribute.new(ac.name, ac.type)} end |