Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rails console tips

rails console

Model

> ActiveRecord::Base.connection.tables.map { |t| "#{t} => " + ActiveRecord::Base.connection.execute("select count(*) from #{t}").fetch_row.first}

This actually uses method ActiveRecord::ConnectionHandling.connection

> ActiveRecord::Migration.add_column 

You need to konw the Model name, and access (both read and write) here.

> JxRailsMd::Aa::Account.all

##Refs

see-all-tables-all-records-from-console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment