activesupport

Rails time_ago_in_words producing bad output

别等时光非礼了梦想. 提交于 2020-01-02 20:13:33
问题 I thought this might be due to moving to activesupport 2.3.5 but now I believe something else must have happened. Model has a valid rfc822 style date: >> s.lastVisitDate => "Thu, 06 Jan 2011 22:24:10 -0800" But in my view: <%=h time_ago_in_words(@site.lastVisitDate) -%> renders: *about {{count}} hours ago* instead of: *about 2 hours ago* which was working just fine earlier. Wondering if anyone else has seen this behavior. I've reviewed my version history for the model and view and nothing has

Rails time_ago_in_words producing bad output

被刻印的时光 ゝ 提交于 2020-01-02 20:13:21
问题 I thought this might be due to moving to activesupport 2.3.5 but now I believe something else must have happened. Model has a valid rfc822 style date: >> s.lastVisitDate => "Thu, 06 Jan 2011 22:24:10 -0800" But in my view: <%=h time_ago_in_words(@site.lastVisitDate) -%> renders: *about {{count}} hours ago* instead of: *about 2 hours ago* which was working just fine earlier. Wondering if anyone else has seen this behavior. I've reviewed my version history for the model and view and nothing has

Active Merchant - uninitialized constant ActiveSupport::XmlMini_REXML::StringIO

时间秒杀一切 提交于 2020-01-02 05:14:17
问题 I have activemerchant 1.16.0 and rails 3.0.5. I am trying to build a basic code to communicate with PayPal's gateway using active merchant. if credit_card.valid? # or gateway.purchase to do both authorize and capture response = gateway.authorize(1000, credit_card, :ip => "127.0.0.1") if response.success? gateway.capture(1000, response.authorization) puts "Purchase complete!" else puts "Error: #{response.message}" end else puts "Error: credit card is not valid. #{credit_card.errors.full

How do I avoid the circular argument reference warning in activesupport

大城市里の小女人 提交于 2019-12-29 06:34:11
问题 How do I avoid the circular argument reference warning in activesupport. Happens on ruby 2.2.0 /home/ec2-user/apps/foo_prod/shared/bundle/ruby/2.2.0/gems/activesupport-3.2.21/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now /home/ec2-user/apps/foo_prod/shared/bundle/ruby/2.2.0/gems/ruby-ole-1.2.11.7/lib/ole/types/base.rb:265: warning: duplicated key at line 266 ignored: 4095 回答1: This is compass issue here. They haven't release new version yet so you may

Why does Rails' `HashWithIndifferentAccess` store keys as strings and not symbols?

爱⌒轻易说出口 提交于 2019-12-24 01:16:17
问题 I am using enum to map integers in my database to semantic values in my ruby code, however I noticed that the keys that it uses are strings. When I checked the type of the hash, I discovered that it was an ActiveSupport::HashWithIndifferentAccess , not a standard Hash , which makes sense, but lead to the question of why Rails chose to store and compare the values as strings, not symbols, internally. The documentation states: Internally symbols are mapped to strings when used as keys in the

What's the differences btw const_get and qualified_const_get?

邮差的信 提交于 2019-12-22 09:28:33
问题 There is a series of methods, i.e., const_defined?, const_get, or const_set, in standard ruby library. const_defined?, const_get, const_set And also, in the Active Support Core Extensions of Rails, their "qualified_" counterparts for these individuals exist. qualified_const_defined?, qualified_const_get, qualifeid_const_set Is there anybody who can explain explicitly the differences between bare and qualified forms for these methods? Thank you in advance. Hyo 回答1: The qualified_ const helpers

Custom Inflections not working on rails3?

偶尔善良 提交于 2019-12-22 07:52:28
问题 I'm using Rails (3.0.1) and have the following code in initializers/inflections.rb ActiveSupport::Inflector.inflections do |inflect| inflect.irregular('nursery', 'nurseries') end From the console I'm getting: "nursery".pluralize => "nurseries" "nurseries".singularize => "nurseries" I should be getting: "nurseries".singularize => "nursery" Any ideas? 来源: https://stackoverflow.com/questions/4028992/custom-inflections-not-working-on-rails3

Custom Inflections not working on rails3?

拜拜、爱过 提交于 2019-12-22 07:52:07
问题 I'm using Rails (3.0.1) and have the following code in initializers/inflections.rb ActiveSupport::Inflector.inflections do |inflect| inflect.irregular('nursery', 'nurseries') end From the console I'm getting: "nursery".pluralize => "nurseries" "nurseries".singularize => "nurseries" I should be getting: "nurseries".singularize => "nursery" Any ideas? 来源: https://stackoverflow.com/questions/4028992/custom-inflections-not-working-on-rails3

Long nil safe method chains [closed]

我的未来我决定 提交于 2019-12-21 05:05:01
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . So I know of a few different approaches that I am aware of and I want explore the advantages and disadvantages of the various ways for various criteria which are: readability performance ease of debugging OO principles (low coupling and high cohesion) Explicitly using the try

Get Time Object at Start of Day in a Particular Time Zone

孤人 提交于 2019-12-20 10:29:07
问题 How can I get a ruby Time object that represents the start of the day on a particular date in a given timezone. 回答1: date = Date.today date.to_time.in_time_zone('America/New_York').beginning_of_day Currently outputs => 2011-11-02 00:00:00 -0400 Time.now.in_time_zone('Asia/Shanghai').beginning_of_day Currently outputs => 2011-11-03 00:00:00 +0800 date = Date.today date.to_time.in_time_zone('Asia/Shanghai').beginning_of_day Currently outputs => 2011-11-02 00:00:00 +0800 回答2: I ended up using