I got the following snippet
Class Artist < ActiveRecord
attr_accessible :solo #boolean
def change_solo!
if self.solo == false
self.solo = true
else
self.solo = false
end
self.save
end
end
Is there a better way to write that? Thanks in advance
cheers tabaluga
Aha! I can shrink it even further, heh:
This does the save automatically.
But it wouldn’t be complete without tests:
By the way, above I use the convention that any boolean attribute in ActiveRecord can have a question mark at the end to make it more self-explanatory.