Rails: How to list database tables/objects using the Rails console?

Rails: How to list database tables/objects using the Rails console?

Asked on January 10, 2019 in Ruby on Rails.
Add Comment


  • 2 Answer(s)

    Using probably wrap them in shorter syntax inside on  .irbrc. 

    
    ActiveRecord::Base.connection.tables
    

    then,

    
    ActiveRecord::Base.connection.table_structure("projects")
    

    Answered on January 10, 2019.
    Add Comment

    Rails database console: 

    rails db
    

    pretty print  query output,

    .headers on
    .mode columns
    (turn headers on and show database data in column mode )
    

    tables,

    .table
    

    Answered on January 10, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.