if you are onyl using this for account models, a plugin is going to be
overkill...why not just do:
class Account < ActiveRecord::Base
before_create :set_expiry_date
# other methods
private
# set the expiry date
def set_expiry_date
self.exp_date = Time.now.end_of_month.to_date.to_s
end
end
ex:
>> Time.now.end_of_month.to_date.to_s
=> "2006-06-30"
note: if you use before_save, every time you save the record, whether
it''s a
new record or an update, the expiry date will be updated to reflect the last
day of the current month...in my example, I used before_create to indicate i
only want the expiry date set when a new record is created.
Chris
On 6/8/06, Alex Wayne <rubyonrails@beautifulpixel.com>
wrote:>
> Mike Haggerty wrote:
> > class Account < ActiveRecord::Base
> > acts_as_expiration_date :exp_date
> > end
>
> Try looking at other acts_as_* plugins and see how they work.
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/8af32fc8/attachment.html