1

I'm trying to figure out which database i'm using in the rails console, i understand it says Loading development environment (Rails 4.2.0), so i'm presuming its whatever database i listed in development in gemfile but i'm not so sure, is there a way of checking this inside the console?, or is it better to just use the psql command line with raw sql, because from what i see, active record queries don't work with the pg command line.

Active record in postgres console.

psql (9.4.0, server 9.2.4)
Type "help" for help.

spencerlong=# User.all
spencerlong-# 

Better yet, a console with postgres AND Active_record capabilities.

2
  • 2
    active record queries don't work with the pg command line yeah, pgsql is no ruby Commented Apr 21, 2015 at 8:23
  • granted yes, so do you know of a way to run postgres database in rails console, (for querying active record) or is it whatever you listed in gemfile under given environment., thats what you'll use. Commented Apr 21, 2015 at 8:25

1 Answer 1

1

Write a below command in rails console to get database name

Rails.configuration.database_configuration["development"]["database"]
Sign up to request clarification or add additional context in comments.

2 Comments

NoMethodError: undefined method `new' for Rails::Configuration:Module is what i get from that.
I just update my post, please see, I have rails 4.0 version, it works for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.