def initialize(*args, &block)
super
print_usage unless scaffold_name.underscore =~ /^[a-z][a-z0-9_\/]+$/
@controller_actions = []
@model_attributes = []
@skip_model = options.skip_model?
@namespace_model = options.namespace_model?
@invert_actions = options.invert?
args_for_c_m.each do |arg|
if arg == '!'
@invert_actions = true
elsif arg.include?(':')
@model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
else
@controller_actions << arg
@controller_actions << 'create' if arg == 'new'
@controller_actions << 'update' if arg == 'edit'
end
end
@controller_actions.uniq!
@model_attributes.uniq!
if @invert_actions || @controller_actions.empty?
@controller_actions = all_actions - @controller_actions
end
if @model_attributes.empty?
@skip_model = true
if model_exists?
model_columns_for_attributes.each do |column|
@model_attributes << Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
end
else
@model_attributes << Rails::Generators::GeneratedAttribute.new('name', 'string')
end
end
end