Can I open a rails console in read-only mode?
Asked Answered
J

1

9

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!

Jaffa answered 2/9, 2011 at 19:54 Comment(0)
C
16

See this question

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

script/console --sandbox
Chongchoo answered 2/9, 2011 at 19:56 Comment(4)
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 also.Freidafreight
@Freidafreight I agree it's not a perfect solutionChongchoo
Thanks! That'll do for my purposes.Jaffa
Nowadays with rails 3 and 4 the command the sandbox console can be accessed via rails c -s.Leveroni

© 2022 - 2024 — McMap. All rights reserved.