Quee WM wrote: > I have an application in rails in which i am adding a new column in one > of the tables. The value for the new column is a bit.ly link and I need > to populate this for each record in the table approx. 250 rows will be > affected. > > Q1: Can this be done outside the application? i.e. write a script that > can interact with the db and then populate the appropriate column? And > is this advisable? > > or > > Q2: if the aforementioned idea is not a good way then what will be the > best way to update the existing records as any code i will write will > only be used to update the table once. Can you update the database outside of your Rails application? Yes. Should you? Many would say NO, but in practice I have never yet encountered an app that was ALWAYS updated only with the app. The DB itself, various utilities, one-time scripts, external apps (e.g., Excel, etc.) are often used. Be careful, have a backup, be careful again, test, then be VERY careful. Using a plain Ruby script to interact with the datavbase is certainly possible, and not necessarily using ActiveRecord. You might consider using something like Sequel (v3.8.0), which is a database toolkit for Ruby (I have NOT used this myself). But, again, be VERY careful. Any updates you do outside your app may NOT conform to your business rules. That's up to you. j -- Posted via http://www.ruby-forum.com/.