KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can I add two weeks to the current Time.now in Ruby? I have a small Sinatra project that uses DataMapper and before saving, I have a field populated with the current time PLUS two weeks, but is not working as needed. Any help is greatly appreciated! I get the following error: NoMethodError at / undefined method `weeks' for 2:Fixnum Here is the code for the Model: class Job include DataMapper::Resource property :id, Serial property :position, String property :location, String property :email, String property :phone, String property :description, Text property :expires_on, Date property :status, Boolean property :created_on, DateTime property :updated_at, DateTime before :save do t = Time.now self.expires_on = t + 2.week self.status = '0' end end
Tags (comma-separated)
Save Edits
Cancel