Skip to content

Instantly share code, notes, and snippets.

@between40and2
Last active August 29, 2015 14:02
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 between40and2/7dd564d50b3ff10b330c to your computer and use it in GitHub Desktop.
Save between40and2/7dd564d50b3ff10b330c to your computer and use it in GitHub Desktop.
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