Skip to content

Instantly share code, notes, and snippets.

@bernEsp
Last active August 29, 2015 14:08
Show Gist options
  • Save bernEsp/c2b4a6133f762548353b to your computer and use it in GitHub Desktop.
Save bernEsp/c2b4a6133f762548353b to your computer and use it in GitHub Desktop.
count all rows in rails app
(ActiveRecord::Base.send :subclasses).inject(0) do |sum, m|
begin
sum + m.all.size
rescue ActiveRecord::StatementInvalid
"no existe"
end
end
ActiveRecord::Base.each_model_class.inject .. add each model class method to active record module on base class
@bernEsp
Copy link
Author

bernEsp commented Oct 24, 2014

@bernEsp
Copy link
Author

bernEsp commented Oct 29, 2014

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