Skip to content

Instantly share code, notes, and snippets.

@tatat
Created November 19, 2012 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatat/4110203 to your computer and use it in GitHub Desktop.
Save tatat/4110203 to your computer and use it in GitHub Desktop.
ActiveRecord::Base.connection.tables.each do |table_name|
next if %w|SchemaMigration Session|.include? table_name.classify
code = <<EOS
class #{table_name.classify} < ActiveRecord::Base
attr_accessible :#{table_name.classify.constantize.column_names.join(', :')}
end
EOS
`echo '#{code}' > app/models/#{table_name.singularize}.rb`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment