Rails mass assignment checker

A quick way to list all you rails models and find out column names an which have been white and blacklisted against mass assignment.

Dir.glob("#{Rails.root}/app/models/*.rb").collect{|m| m.split("/").last.split(".").first.camelize.constantize }
models = ActiveRecord::Base.subclasses.collect(&:name).collect(&:constantize)

models.each{|m| puts m; print "Columns:    #{m.column_names}"; puts ""; print "Protected:  #{m.attr_protected.to_a}"; puts ""; print "Accessible: #{m.attr_accessible.to_a}"; puts "\n\n" }

# example output
#
#User
#Columns:    ["id", "email", "encrypted_password", "salt", "confirmation_token", "remember_token", #"created_at", "updated_at", "company_id", "status"]
#Protected:  ["id", "type", "status", "company_id"]
#Accessible: []