search for: from_now

Displaying 20 results from an estimated 52 matches for "from_now".

2006 Mar 31
4
Date magic?
Hi. When I read Dave and Davids excellent book "Agile Web Development with Rails" the first time, I was particularly impressed with the following statement: 1.day.from_now It was used in a test class to set the date of tomorrow dynamically. Since it was enclosed in in ERb tags, I assumed this was a normal ruby statement, but when I tried it in my irb, i get the following error: irb(main):007:0> 1.day.from_now NoMethodError: undefined method `day'' for 1:F...
2006 Feb 24
1
RailsCron: Trigger one time
...mple code to try this, but the behavior of some combinations of start, every, and finish behave in some unpredictable ways. 3 class RailsMaintainer 4 include ActsAsBackground 5 background :remove_sessions, :start => Time.now, :every => 7.minutes, :finish => 5.minutes.from_now 6 7 8 def self.remove_sessions 9 f = File.new("testfile", "a+") 10 fmt = "%d %b %Y at %I:%M:%S %p" 11 12 f << "The time is: " << Time.new.strftime(fmt) << "\n" 13 f.close...
2008 Aug 30
3
Working with sessions in beast forum
...ut I''m baffled about how (and where exactly) I have to do it. The following code is used when creating a session: class SessionsController < ApplicationController def create if using_open_id? cookies[:use_open_id] = {:value => ''1'', :expires => 1.year.from_now.utc} open_id_authentication else cookies[:use_open_id] = {:value => ''0'', :expires => 1.year.ago.utc} password_authentication params[:login], params[:password] end end protected def open_id_authentication authenticate_with_open_id params...
2012 Apr 25
8
showing error (gsub) when switching from session to cookies
..."0") elsif param_posted?(:user) @user = User.new(params[:user]) user = User.find_by_screen_name_and_password(@user.screen_name, @user.password) if user user.login!(session) if @user.remember_me == "1" cookies[:remember_me] = { :value => "1", :expires => 10.years.from_now } user.authorization_token = user.id user.save! cookies[:authorization_token] = { :value => user.authorization_token, :expires => 10.years.from_now } else cookies.delete(:remember_me) cookies.delete(:authorization_token) end flash[:notice] = "User #{user.screen_name} logged in!"...
2006 Feb 23
1
RailsCron: ''every'' in background
Got another question. It''s unclear to me what "every" means in the background function and how it relates to the RailsCron.create "every": >From README: RailsCron.create( :command => "Object.do_something()", :start => 2.minutes.from_now, :every => 12.hours, # default: 1.day :finish => 2.years.from_now # optional ) class EmailQueue < ActiveRecord::Base background :deliver, :every => 1.minute, :concurrent => true def self.deliver #process the queue...
2006 Mar 06
2
Cookies & gsub ?
...This works: @params.each_pair do |this_index, this_param| cookies[this_index] = this_param end Except, I get session-only cookies. This doesn''t work: @params.each_pair do |this_index, this_param| cookies[this_index] = { :value => this_param, :expires => 30.days.from_now } end Specifcally, I get the error: > private method `gsub'' called for ["Sonic", "0"]:Array I''m not entirely sure I understand why one of these works, but the other doesn''t. Can someone point me in the right direction here? -------------- ne...
2006 Dec 01
2
Mongrel 0.3.18, rails 1.1.6 and cookies
...operly create the first cookie in the list.) I''m at home right now, but when I get back into work tomorrow, I''ll try to install 0.3.15 and see if the problem exists there as well. Thanks. def login cookies[:auth_token] = { :value => "auth", :expires => 10.years.from_now.utc } cookies[:userid] = { :value => "100", :expires => 10.years.from_now.utc } end
2006 Jan 07
3
RailsCron 0.1 plugin
...: OVERVIEW ======== RailsCron is a way to execute background tasks using your Ruby on Rails environment. The RailsCron object is an ActiveRecord, so you can manipulate it in familiar ways: RailsCron.create( :command => "Object.do_something()", :start => 2.minutes.from_now, :every => 12.hours, # default: 1.day :finish => 2.years.from_now # optional ) RailsCron.destroy_all RailsCron.find_by_command "some_command" Cron, when used with RoR, has the following shortcomings: * Significant startup resources req...
2008 Oct 11
1
Re: time_ago_in_words is off by a day
Look at your 1.day.from_now and see if it''s like this: Sun, 12 Oct 2008 02:45:42 UTC +00:00 If you also have the "UTC +00:00", it means that you timezone is the GMT (and I think that it isn''t your real timezone). For example, my timezone is 3 hours after the GMT, so the right timezone would be so...
2007 Jan 29
2
rspec and cookies
...quest and also to test the cookies which have been set by a get/post request I know I can use cookies[:name] = ''value'' to set a cookie but how would I set expiry information on such a cookie? when i try to pass a hash {:value => ''value'', :expires => 3.days.from_now} the entire hash becomes the value of cookies[:name] thanks david -- View this message in context: http://www.nabble.com/rspec-and-cookies-tf3134883.html#a8686339 Sent from the rspec-users mailing list archive at Nabble.com.
2008 Dec 16
3
ApplicationProperties
...permissions to them ... I tried creating something like this: class ApplicationProperties < ActiveRecord::Base def facebook_session @facebook_session ||= returning Facebooker::Session.create do |session| session.secure_with!(session_key,User.find(:first).facebook_id,1.hour.from_now) end end end but that doesn''t seem to help, i.e. the facebook session thing is specific to the user model .... Many thanks in advance CHEERS> SAM -- Sam Joseph, Ph.D. Co-Director Laboratory for Interactive Learning Technologies Department of Information and Computer Science...
2007 Feb 13
7
Specs of code that use Time.now
...ntil date to this time tomorrow. I''ve done something similar involving Dates, and you can stub the :today method to return something fixed. But when I tried this with Time, I found that RSpec calls Time.now four times per spec. So there''s no way to spec code like 1.days.from_now . The best I can come up with is this: context "A Quote" do setup do @quote = Quote.new end specify "should set the default valid_until date to this time tomorrow" do @quote.valid_until.should_be_between(1.days.from_now - 1.second, 1.days.from_now + 1...
2006 Jun 20
9
secure downloads
Has anyone had any success with the mongrel_secure_download gem? I keep getting "connection reset" errors. -- Cheers, Kevin
2007 Jul 17
0
Backgroundrb scheduler seems to stop running
I have two scheduled tasks in my rails app: background_schedules.yml mail_sender_1: :class: :mail_sender_worker :job_key: :job_key_mail_sender_1 :worker_method: :do_work :trigger_args: :start: <%= Time.now + 5.seconds %> :end: <%= 1.years.from_now %> :repeat_interval: <%= 60.minutes %> cleanup_1: :class: :cleanup_worker :job_key: :job_key_cleanup_1 :worker_method: :do_work :trigger_args: :start: <%= Time.now + 30.minutes %> :end: <%= 1.years.from_now %> :repeat_interval: <%= 60.minutes %>...
2006 May 10
3
formatted date down-counter - help!
I''d like to have a count down to a certain date, but display it in words, such as "123 days away" or something. I''m aware of the function "distance_of_time_in_words_to_now()", which will display "about 6 hours" or "12 days" or something like that, but how can I get it to reverse? Pass it a date for future reference, then it will error
2006 Feb 11
2
Session ID in a cookie?
I''ve been looking around for how to store the session ID in a cookie. The "Agile Web Development with Rails" books seems to indicate that this is done by default with Rails. But I don''t see a cookie being set in my browser. (yeah, they''re enabled) I poked through the RForum code to find something referencing "cookies" but nothing came up. Does
2005 Dec 30
2
before_create question
...weird thing is, if the registration deadline has passed, the error gets added to the registration object, and calling save! throws no exception, but the registration object doesn''t get saved. So, this test code throws no exception: event = TrainingEvent.new :start_date => 19.days.from_now, :end_date => 22.days.from_now, :capacity => 10 reg = Registration.create :training_event => event, :user => @bob, :role => @community_director, :program_number => ''asdf'' assert_equal reg.er...
2008 Apr 25
0
Date validation :before -1 day
I really liked the tool but I have got stuck in one case. I am in urgent need of your help regarding validates_date :sale_start, :before => :sale_end, :after => Proc.new { -1.day.from_now.to_date } validates_date :sale_end, :after => [:sale_start , Proc.new { -1.day.from_now.to_date }], This is Okay but there may be the same date as of sale_end. Means a sale can be for a single day, in that case sale_start and sale_end both fields may...
2009 Jul 02
2
Big help with shared subdomains cookies
...om'' as domain for all cookies. I''ve set ActionController::Base.session_options[:domain] = ''.domain.com'' and it works...for just the session... how can i set this also for common cookies ? (created with cookies[:name] = {:value => value, :expires => 6.months.from_now} ) -- Posted via http://www.ruby-forum.com/.
2010 Aug 09
0
Logging form delayed job class
...BufferedLogger.new("log/ ##{Rails.env}_delayed_jobs.log", Rails.logger.level) class Delayed::Job def logger Delayed::Worker.logger end end if JobsCommon::check_job_exists("PeriodicJob").blank? Delayed::Job.enqueue PeriodicJob.new(), 0, Constants::PROCESS_FREQ.from_now end #end This is my job class class PeriodicJob def perform this.logger.info "Periodic job writing #{Time.now}" # Rails.logger.info "Periodic job writing #{Time.now}" if JobsCommon::check_job_exists("PeriodicJob").blank? Delayed...