activesupport

Rails; Autoload issue after installing Sidekiq: ArgumentError (A copy of Api::V1 has been removed from the module tree but is still active!):

懵懂的女人 提交于 2020-07-22 05:51:48
问题 I have a rails (v5.1) project in development, in which I recently installed Sidekiq. I now have an autoload issue, getting the subject argument error. I have done a fair bit of research which seem to boil down to this being a problem of "trying to access an automatically reloaded class (in app directory) from one that is not automatically reloaded (in lib directory)," and that when the code is reloaded, Rails throws an error since the module from which the constant search is starting shouldn

Ruby not finding new version of OpenSSL

亡梦爱人 提交于 2020-01-21 04:11:13
问题 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

Ruby not finding new version of OpenSSL

倾然丶 夕夏残阳落幕 提交于 2020-01-21 04:10: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

How do I require ActiveSupport's rescue_from method?

大兔子大兔子 提交于 2020-01-12 14:11:38
问题 I have this code in application controller : # Method to capture and handle all exceptions rescue_from Exception do |ex| Rails.logger.debug ex do_stuff(ex) end I want to move this into a module and then: class ApplicationController < ActionController::Base include 'module' ... Right now my module looks like: # lib/exception_mailer.rb require 'action_mailer' require 'active_support' module ExceptionMailer # Method to capture and handle all exceptions rescue_from Exception do |ex| ... And I am

How do I require ActiveSupport's rescue_from method?

橙三吉。 提交于 2020-01-12 14:10:51
问题 I have this code in application controller : # Method to capture and handle all exceptions rescue_from Exception do |ex| Rails.logger.debug ex do_stuff(ex) end I want to move this into a module and then: class ApplicationController < ActionController::Base include 'module' ... Right now my module looks like: # lib/exception_mailer.rb require 'action_mailer' require 'active_support' module ExceptionMailer # Method to capture and handle all exceptions rescue_from Exception do |ex| ... And I am

How do I require ActiveSupport's rescue_from method?

不羁岁月 提交于 2020-01-12 14:10:44
问题 I have this code in application controller : # Method to capture and handle all exceptions rescue_from Exception do |ex| Rails.logger.debug ex do_stuff(ex) end I want to move this into a module and then: class ApplicationController < ActionController::Base include 'module' ... Right now my module looks like: # lib/exception_mailer.rb require 'action_mailer' require 'active_support' module ExceptionMailer # Method to capture and handle all exceptions rescue_from Exception do |ex| ... And I am

Rails: get #beginning_of_day in time zone

☆樱花仙子☆ 提交于 2020-01-12 03:13:05
问题 I have a default time zone setup for the rails application. And an instance of the Date object. How can I get make Date#beginning_of_day to return the beginning of the day in the specified time zone, but not my local timezone. Is there any other method to get beginning of the day time in the specified timezone for the given date? date = Date.new(2014,10,29) zone = ActiveSupport::TimeZone.new('CET') date.foo(zone) # should return "Wed, 29 Oct 2014 00:00:00 CET +01:00" zone = ActiveSupport:

Rails: get #beginning_of_day in time zone

风流意气都作罢 提交于 2020-01-12 03:11:14
问题 I have a default time zone setup for the rails application. And an instance of the Date object. How can I get make Date#beginning_of_day to return the beginning of the day in the specified time zone, but not my local timezone. Is there any other method to get beginning of the day time in the specified timezone for the given date? date = Date.new(2014,10,29) zone = ActiveSupport::TimeZone.new('CET') date.foo(zone) # should return "Wed, 29 Oct 2014 00:00:00 CET +01:00" zone = ActiveSupport:

Is there a way to overwrite the `{ }` object?

半世苍凉 提交于 2020-01-11 11:11:50
问题 I'm trying to make all Hashes in my program be ActiveSupport::OrderedHash. I can override the Hash.new constructor by ::Hash = ActiveSupport::OrderedHash but {}.class is still hash. def {} gives me a syntax error. It was recommended that this is a duplicate of this question, but I don't think that is the case. My question isn't about subclassing Hash, it's about overwriting the default { } => Hash constructor. 回答1: Hash literal {} is hard-coded in Ruby, and you cannot change it. {} will

How do you know when to use an XML parser and when to use ActiveResource?

流过昼夜 提交于 2020-01-05 03:20:28
问题 I tried using ActiveResource to parse a web service that was more like a HTML document and I kept getting a 404 error. Do I need to use an XML parser for this task instead of ActiveResource? My guess is that ActiveResource is only useful if you are consuming data from another Rails app and the XML data is easily translatable to a Rails model. For example, if the web service is more wide-ranging XML like a HTML document or an RSS feed, you want to use a parser like hpricot or nokogiri. Is this