You can do the equivalent of a SQL UPDATE command by using update_all:
MyModel.update_all "myfield = Yes", "myfield = 1"
BUT, why would you do this? Leaving it as one/zero gives you some
free behavior in your model. Let's say your column is called
'activated' or something like that. Leave it as 1/0 and you can do:
This will return true if it's a 1, false otherwise.
If you need to display "yes" or "no" somewhere in a view, and that's
why you're changing the data, then you can write a helper method to do
model.activated == '1' ? 'Yes' : 'No'
and then in your view:
<%= display_activated(@model) %>
But again, I'm not sure why you need to change the data, so my
suggestions may or may not be appropriate...? Let me know.
www.essentialrails.com - 2-Day Rails training for beginners. Rails
made simple. And fun.