Displaying 7 results from an estimated 7 matches for "beginning_of_week".
2009 Feb 27
2
Modify beginning_of_week?
Hello everyone!
Is it possible to modify this function: beginning_of_week?
What I want is something like this :
beginning_of_week(0) returns Sunday
beginning_of_week(1) returns Monday
Thank you!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups &qu...
2006 Oct 24
13
How can my boss take rails seriously with bugs like this?
The Time::next_week method is supposed to give the time of the start of
the next week. But look at this, it cocks up :
>> t=Time.parse "Monday October 16th 2006"
=> Mon Oct 16 00:00:00 BST 2006
>> t.next_week
=> Mon Oct 23 00:00:00 BST 2006
>> t.next_week.next_week
=> Tue Oct 24 00:00:00 BST 2006
>> t.next_week.next_week.next_week
=> Mon Oct 30
2013 Mar 04
0
fields_for with accepts_nested_attributes: how to pass a value to a label
I can''t figure out how to pass a value from the following object build in
the controller:
class TimesheetsController < AC
...
def new
@timesheet = current_user.timesheets.new
now = Date.today
#generating 7 time entries: monday through sunday
(now.beginning_of_week..now.end_of_week).step { |date|
@timesheet.time_entries.build(:workdate; date)
end
end
...
In the Timesheet model I defined accepts_nested_attributes for time_entries
association:
class Timesheet < AR
has_many :time_entries, :dependent: :destroy
accepts_nested_attributes_for :time_entr...
2009 Jun 07
17
ActiveRecord Classes
I''m having a little trouble with understanding how to work out the
schematic for some of my classes using ActiveRecord when a file is in my
lib directory:
Brief example:
Here''s the outline of the files in use:
....app
........controllers
............application_controller.rb
............rushing_offenses_controller.rb
........models
............rushing_offense.rb
....lib
2013 Jun 27
2
Date.weekend?
Hello,
Having a boolean *.weekend?* on the Date class would be a good feature. It
will basically do this:
saturday? || sunday?
Makes the code cleaner and easier to read.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
2008 Nov 21
5
Getting the number of years between two dates
Hey,
I need to get the number of years (as a number) between two dates. Here is
what I have as a helper.
# Returns the number of years between now and the specified date.
def years_ago(date)
dateDifference = DateTime.now - date
results =Date.day_fraction_to_time(dateDifference)
return results[0] / 24 / 365;
end
I''m sure there is a better way to do this. What is it?
2009 Jul 02
7
Params Merge and URL sorting/pagination
...formatted
properly due to form_tag lacking model validation checks
datevar = todaysdate if datevar.empty? || datevar.nil? ||
DATE_VALIDATE_REG.match(datevar).nil?
# we need to convert datevar to time and find the beginning of that
week for scope comparison
convert_time = datevar.to_time.beginning_of_week
# we need to reconvert the time back to a readable week start date
week_start_date = convert_time.to_date.strftime(''%Y-%m-%d'')
# using our named scope to checked for compiled_on which is a date
type column to search within specified date ranges
named_scope :compile...