activesupport

Bundler could not find compatible versions for gem “activesupport”

会有一股神秘感。 提交于 2019-12-01 15:17:36
问题 I migrated to 3.2.13 version of rails and I am getting this error, how do I get rid of this? Fetching gem metadata from https://rubygems.org/....... Fetching gem metadata from https://rubygems.org/.. Resolving dependencies... Bundler could not find compatible versions for gem "activesupport": In snapshot (Gemfile.lock): activesupport (3.2.12) In Gemfile: rails (= 3.2.13) ruby depends on activesupport (= 3.2.13) ruby Running `bundle update` will rebuild your snapshot from scratch, using only

How to change default format of Date in Rails 3?

牧云@^-^@ 提交于 2019-12-01 09:18:30
问题 I'm having problem with the date format of rails. It seems to me that the default Date Format is dd/mm/yyyy . How am I gonna change it to something like mm/dd/yyyy ? I read somewhere that ActiveSupport gem can handle this but I don't how it works. 回答1: Put following line in your enviroment.rb Date::DATE_FORMATS.merge!(:default => "%m/%d/%Y") and try Time.now.to_date.to_s On you rails console 回答2: You can add the file into the config/initializers folder having name i.e. (date_time_formats.rb).

Overriding methods in an ActiveSupport::Concern module which are defined by a class method in the same module

佐手、 提交于 2019-12-01 03:34:46
I have an ActiveSupport::Concern module which looks roughly like the following: module MyModel module Acceptance extend ActiveSupport::Concern included do enum status: [:declined, :accepted] end def declined! self.status = :declined # some extra logic self.save! end def accepted! self.status = :accepted # some extra logic self.save! end end end This is only ever going to be included into ActiveRecord classes, hence the use of enum . Basically, I'm overriding the declined! and accepted! methods that are created by ActiveRecord::Enum.enum with some extra, custom logic of my own. The problem is,

Ruby not finding new version of OpenSSL

旧时模样 提交于 2019-11-30 17:26:14
Where and when does OpenSSL::OPENSSL_VERSION_NUMBER get set? And why isn't it getting set to the latest OpenSSL that I've just installed? First the error(s): $ gem install activesupport -v '3.2.13' Error while executing gem ... (RuntimeError) Unsupported digest algorithm (SHA512) If I go directly into irb, I can see that Ruby is using the "old" openssl: $ irb >> require 'openssl' => true >> OpenSSL::Digest.new('sha512') RuntimeError: Unsupported digest algorithm (sha512) >> OpenSSL::OPENSSL_VERSION_NUMBER.to_s(16) "9070cf" This tells me that Ruby isn't finding the local version of OpenSSL that

How to use NSTimeZone -timeZoneWithName: with a city name from Rails ActiveSupport?

拜拜、爱过 提交于 2019-11-30 11:09:24
If I only have the city name like Bangkok or Tokyo , how can I supply a timezone parameter in [NSTimeZone timeZoneWithName:@"Asia/Tokyo"] where it also has continent and slash in front of city? I already tried [NSTimeZone timeZoneWithName:@"Tokyo"] , it doesn't work. Thanks for the answers guys, but it looks like those city names are just a format that Rails "ActiveSupport::TimeZone" uses. So I just have to map it back. The mapping is here -> http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html It maps the timezone from Rails "ActiveSupport::TimeZone" format to another format that

Cannot define multiple 'included' blocks for a Concern (ActiveSupport::Concern::MultipleIncludedBlocks) with cache_classes = true

纵饮孤独 提交于 2019-11-30 10:49:48
I have a certain module which is used in a Rails 4.1.1 application module A extend ActiveSupport::Concern included do #Some code end end which is included in a class class Some include A end This works great with cache_classes=true in application.rb . Now, if I turn off the caching of classes, I get Cannot define multiple 'included' blocks for a Concern (ActiveSupport::Concern::MultipleIncludedBlocks) exception upson starting the server. How should one deal with such an issue since reloading the classes is done by Rails? For anyone hitting the same wall to read, the solution to this is to

converting Date object to TimeWithZone

无人久伴 提交于 2019-11-30 09:47:42
I need to convert a Date object into a TimeWithZone object representing the beginning of that day in a given time zone. The following approach works, but seems too convoluted as it requires me to convert the date to a string: ?> date = Date.parse("2010-02-17") => Wed, 17 Feb 2010 >> ActiveSupport::TimeZone['Eastern Time (US & Canada)'].parse(date.to_s) => Wed, 17 Feb 2010 00:00:00 EST -05:00 >> ActiveSupport::TimeZone['UTC'].parse(date.to_s) => Wed, 17 Feb 2010 00:00:00 UTC 00:00 Is there a better way I'm missing? Edit: People are suggesting variations of: ?> date.to_datetime.in_time_zone(

validates_inclusion_of no longer working the same in Rails 4.1?

梦想与她 提交于 2019-11-30 09:30:19
The following code made sure that a time_zone chose is within the time zones in ActiveSupport::TimeZone.us_zones : validates_inclusion_of :time_zone, in: ActiveSupport::TimeZone.zones_map(&:name) Worked great in Rails 4.0. Just upgraded to Rails 4.1 and I'm getting this error on my index page (so just simply viewing the models): An object with the method #include? or a proc, lambda or symbol is required, and must be supplied as the :in (or :within) option of the configuration hash I'm guessing from that, ActiveSupport::TimeZone.zones_map(&:name) is no longer a valid value for the in property?

How to convert MS excel date from float to date format in Ruby?

走远了吗. 提交于 2019-11-30 07:13:15
Trying to parse and XLSX file using roo gem in a ruby script. In excel dates are stored as floats or integers in the format DDDDD.ttttt, counting from 1900-01-00 (00 no 01) . So in order to convert a date such as 40396 - you would take 1900-01-00 + 40396 and you should get 2010-10-15, but I'm getting 2010-08-08. I'm using active_support/time to do calculation like so: Time.new("1900-01-01") + 40396.days Am I doing my calculation wrong or is there a bug in active support? I'm running ruby 1.9.3-mri on Windows 7 + latest active_support gem (3.2.1) EDIT I was looking at the older file in Excel

Use Rails 3's ActiveSupport core extensions outside rails

懵懂的女人 提交于 2019-11-29 21:15:42
I'm having a problem using ActiveSupport's core extensions on a gem I am developing. I had it working with AS 2.3.8, but as soon as I wanted to port it to 3b4, the extensions stopped working and my test results are filled with lines such as: undefined method `blank?' for "something":String I've included it via gem "activesupport" followed by require "active_support" Is there anything else I need to call to include those extensions? Thanks ActiveSupport is more separate now in Rails 3. If you want the all active_support thing, you can require 'active_support/all' now. But if you want only the