|
I'm brand new to rails. What's the "right way" to change just one field in a database table? I want to do UPDATE ratings SET text="blahblah" WHERE text="balhblah" I thought that the right way would be through generating a migration, but it looks like that's just for updating the structure of the database, rather than the contents (correct me if I'm wrong). How do I change this one field, besides doing it manually through dbconsole (which would screw up the versioning)?
|
# ¿ Mar 19, 2012 05:05 |
|
|
# ¿ Apr 19, 2024 16:25 |
|
prom candy posted:Checkout ActiveRecord's update_all method. You're trying to update a number of records, correct?
|
# ¿ Mar 19, 2012 05:22 |
|
prom candy posted:So you're looking to do the most basic update operation then. Open up your console and do something like. Also, the database was migrated from the old php setup, so the values in this table aren't derived from a seed file I can edit. I thought that the appropriate way to do this was to make a db:migrate operation, but it seems like that's for changing database structures, not contents. Is that assumption wrong? Otherwise, I suppose I will make a custom rake task, but that means that I will have to manually run it in each environment, right? Thanks for your help, guys. I started learning this stuff just two days ago, and I know I've got a lot to learn.
|
# ¿ Mar 19, 2012 14:54 |