8

I'm used to interrogating my rails db via script/console.

But in some instances I need to be exceptionally careful about not changing data, so I'd like to be able to open the console in a read-only mode.

Is there any way to do this?

Thanks!

brahn
  • 12,096
  • 11
  • 39
  • 49

1 Answers1

16

See this question

Can I specify in database.yml that a rails environment should have readonly access to the DB?

script/console --sandbox
Community
  • 1
  • 1
spike
  • 9,794
  • 9
  • 54
  • 85
  • 2
    That's not really "read-only" (but it's as close as you can get), since database changes will be made, although they will be rolled back (hopefully successfully) when the console exits. See [this question](http://stackoverflow.com/questions/4881646/rails-3-sandbox-console) also. – Zabba Sep 02 '11 at 19:58
  • @Zabba I agree it's not a perfect solution – spike Sep 02 '11 at 20:05
  • Thanks! That'll do for my purposes. – brahn Sep 05 '11 at 01:45
  • Nowadays with rails 3 and 4 the command the sandbox console can be accessed via `rails c -s`. – antinome Apr 17 '15 at 15:38