Reputation: 1785
I'm using Netbeans to develop my RoR project so it is managing the SQL database. How can I make quick changes (i.e. edit row-by-row) to my DB, preferably in command line?
i'm thinking - changing temporary passwords and users for testing purposes. Thanks for your input!
Upvotes: 0
Views: 954
Reputation: 20667
Try using ruby script/console
in your rails application directory. From there, you can do things like:
u = User.find(:first)
u.password = 'something_else'
u.save
or
users = User.find(:all)
users.each { |u| u.password = 'something'; u.save }
which will update all users' passwords.
Upvotes: 2
Reputation: 115372
Two ways:
run script/console
and manipulate your Rails' model objects directly from the command line
run script/dbconsole
which will drop you into the command line for your RDBMS (assuming that your database.yml
file is configured to access your database correctly). Then use SQL to do what you need to do
Upvotes: 3
Reputation: 237060
You could just use the direct mysql interface, but I'd use script/console to go through your model classes unless you really need direct DB access.
Upvotes: 0