class AttrAccessible2StrongParams
Constants
- VERSION
Public Class Methods
convert(file_or_dir, no_rename = false)
click to toggle source
# File lib/attr_accessible2strong_params.rb, line 6 def self.convert(file_or_dir, no_rename = false) @files = [] if file_or_dir.nil? or not File.exist?(file_or_dir) puts 'aa2sp [filename OR dirname]' return end if File.directory?(file_or_dir) Find.find("#{file_or_dir}/app/models/") do |path| next if path.end_with? '.rb.rb' @files << path if path.end_with? '.rb' end else @files << file_or_dir if File.exist? file_or_dir end @files.each do |filename| c = AttrAccessible2StrongParams::Converter.new next if c.read_attr_accessible(filename).blank? print(filename, ' found:', c.model_fields) c.remove_attr_accessible_from_model(filename, no_rename) c.write_controller_with_strong_params(nil, no_rename) puts end end