Displaying 1 result from an estimated 1 matches for "mark_as_unpaid".
Did you mean:
mark_as_paid
2007 Mar 09
0
New plugin: Flagger
...ng to
write repetitive bundles of methods such as
class Order < ActiveRecord::Base
def self.paid
find_all_by_paid(true)
end
def self.unpaid
find_all_by_paid(false)
end
def mark_as_paid
update_attribute(:paid, true)
# related tasks
end
def mark_as_unpaid
update_attribute(:paid, false)
# related tasks
end
end
It gives you dynamic attribute-based methods similar to these. You can
use certain negative prefixes to look for false values - Order.unpaid
returns orders where paid is false - and chain attributes together, as
in Order.paid...