Rafa Perez
2013-Apr-28 22:17 UTC
[ActiveSupport] Add a "remaining_to" method to date class
Just that: class Date> def remaining_to(date) > if date.acts_like? :date > date - self > end > end >alias :days_to end and then be able to do this: Date.today.remaining_to(Date.parse ''2014-04-02'').days.seconds -- 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 rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Rafael Mendonça França
2013-Apr-29 14:20 UTC
Re: [ActiveSupport] Add a "remaining_to" method to date class
Thank you for the suggestion, but I think we don''t need to add this to Active Support since the implementation is really easy and I don''t see Rails or a lot of applications taking advantage of it. Rafael Mendonça França http://twitter.com/rafaelfranca https://github.com/rafaelfranca On Sun, Apr 28, 2013 at 7:17 PM, Rafa Perez <venezuela.gtug@gmail.com>wrote:> Just that: > > class Date >> def remaining_to(date) >> if date.acts_like? :date >> date - self >> end >> end >> > alias :days_to > > end > > > and then be able to do this: > > Date.today.remaining_to(Date.parse ''2014-04-02'').days.seconds > > > > -- > 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 rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Rafa Perez
2013-Apr-30 01:45 UTC
Re: [ActiveSupport] Add a "remaining_to" method to date class
It''s ok... Actually I did not think about the implementation. It''s pretty simple. Well was a newbie suggestion... sorry about that. Thanks for your reply! -- 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 rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Possibly Parallel Threads
- Suggestion: `before_save on: :create` should either work or raise an exception
- #asset_url helper method
- Suggestion: use `select` values if `pluck` called with no args
- validates :boolean_field, presence: true misconceptions
- attr_accessible on some properties + attr_protected on others makes class 'open-by-default'