The tables method has been deprecated:
ActiveRecord::Base.connection.tables
DEPRECATION WARNING: #tables currently returns both tables and views. This behavior is deprecated and will be changed with Rails 5.1 to only return tables. Use #data_sources instead. (called from irb_binding at (irb):2)
> ActiveRecord::Base.connection.data_sources=> ["schema_migrations", "ar_internal_metadata", "products"]
You can then list the columns and it's type like this:
Product.columns.map{ |c| [c.name, c.type]}
=>
[["id", :integer],
["name", :string],
["price", :decimal],
["created_at", :datetime],
["updated_at", :datetime]]
No comments:
Post a Comment