Questions tagged [activesupport]
Active Support is the Ruby on Rails component responsible for providing Ruby language extensions, utilities, and other transversal stuff.
0
votes
0answers
13 views
After upgrade to Mojave Rails app fails in active support
After upgrade to Mojave, my ruby v2.4.1/rails v5.0.0.1 app which worked fine prior to upgrade fails:
activesupport (5.0.0.1) lib/active_support/message_encryptor.rb:72:in `key='
72: cipher.key = @...
1
vote
1answer
26 views
How to spy just one call of ActiveSupport::Notifications #instrument, not all of them
I'm making a Rspec test that checks if ActiveSupport::Notification.instrument was called with some parameters.
The thing is that in order to make this test a need FactoryBot to build some objects, ...
0
votes
1answer
58 views
I want the code will check if the rows=0 then it will add append once. otherwise it will only change its color
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="...
6
votes
2answers
111 views
Extend the ActiveSupport::Notifications.subscribe, instantiation.active_record hook
I am exploring ActiveSupport::Notifications, and would like more information about 'instantiation.active_record', than just the :record_count and :class_name [1]. For example,
ActiveSupport::...
0
votes
0answers
62 views
ActiveLdap Sinatra is giving error while running the application
in Gemfile;
gem 'activeldap'
gem 'netldap'
in file boot.rb;
require 'thread'
require 'rubygems'
require 'active_ldap'
$ldap = ActiveLdap::Base.establish_connection(host: 'somehost', port: 636, ...
1
vote
1answer
68 views
Retrieve list of instance methods that are defined in rails class excluding inherited and included methods
I have a class Product in my rails project, I am trying to retrieve a list of instance methods of my class that are defined in my file (not inherited method or included via mixin). Here's a small ...
1
vote
1answer
43 views
Rails 5.2 cache key for relations generating two queries
I have a view using fragment caching for an ActiveRecord relation, e.g.
<% cache MyModel.all do %>
...
<% end %>
I see two DB queries generated in this case
SELECT COUNT(*) AS "size", ...
1
vote
1answer
32 views
What is the `ActiveSupport::Cache::FileStore` key limit?
I am using Rails Model caching. When generating cache file, I am giving different formats to store data. Because of that, it takes 140-180 length file name, for example:
...
1
vote
5answers
101 views
Get current 1 year from_now as number
How I can get the next year from now?
1.year.from_now
I need to get only 2019 as a result from the above code.
0
votes
0answers
26 views
Rails ActiveSupport can't dump anonymous class on caching
I have the following in my user model:
class User < AR::Base
has_many :domains
has_many :cached_domains, class_name: "Domain"
def cached_domains
Rails.cache.fetch(["Users", id, 'domains'...
0
votes
0answers
117 views
Activesupport and openssl: key must be 32 bytes
I've a rails 4.2.1 project that needs a gem with a dependency on openssl 2.1.1. My ruby version is 2.3.1. When I add the openssl gem, i get the following error for any of the page I load:
lib/...
0
votes
0answers
14 views
LoadError: Unable to autoload constant - guard not picking up custom inflectors
I added some acronyms to my config/initializers/inflections.rb file, and tests run perfectly if I run ./bin/rails test.
I also have guard for minitest set up, but when I run the tests with guard, I ...
0
votes
2answers
55 views
Get full time zone name given an instance of ActiveSupport::TimeWithZone
Given an ActiveSupport::TimeWithZone time instance, how can I return a full time zone name for the time instance?
From the ActiveSupport docs:
Time.zone = 'Eastern Time (US & Canada)' # => "...
0
votes
1answer
38 views
activesupport causing “No such file to load — application (LoadError)”
I'm in the process of upgrading a very old app, and all hell is breaking loose. I'm using ruby 2.1.5, rails 4.2.10, and activesupport 4.2.10.
Lots of people on Google with similar issues, but nothing ...
1
vote
1answer
653 views
Rails 5.2.0 load application error: ActiveSupport::MessageEncryptor::InvalidMessage (ActiveSupport::MessageEncryptor::InvalidMessage
I have tried solutions, which are posted below links:
Rails 5.2 with master.key Digital Ocean deployment: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::...
0
votes
0answers
25 views
How to change single tag to include CDATA with to_xml in ruby?
Tl;dr: How to add CDATA block without new lines in some tags with to_xml from ActiveSupport::XmlMini?
Since yesterday I've sat down and tried to monkey patch ActiveSupport::XmlMini.to_tag(key, value, ...
0
votes
1answer
223 views
Decrypting Rails 5 session manually when secret_key_base is nil?
I'm following several other SO threads on how to manually decrypt a session string...
cookie = CGI::unescape(params[:session])
salt = Rails.application.config.action_dispatch....
2
votes
3answers
155 views
Rails with postgresql: extract field from time is not working
I have a problem with ordering a collection by hour. But first things first.
Project details:
Rails version 5.1.3
Ruby version 2.4.1-p111 (x86_64-linux)
Database adapter ...
0
votes
0answers
182 views
rails 5, decrypt_and_verify, NameError (uninitialized constant ActiveRecord::AttributeSet):
I have a problem with my rails app.
When I want running this
def self.decrypt(encrypted_data, secret_key)
passphrase=ActiveSupport::KeyGenerator.new(secret_key).generate_key(secr et_key,32)
...
1
vote
1answer
89 views
how to use active support core ext date and time
What is active_support/core_ext/date_and_time/calculations for? There are /date, /time, and /date_time for Date, Time and DateTime, respectively. But what is /date_and_time for?
I tried to require it ...
0
votes
0answers
89 views
Rails 4.2.10 upgrade TypeError: ActiveSupport::Duration can't be coerced into Fixnum
I Just upgraded old rails app (3.2.22) to rails 4.2.10 and I am not sure if this is the right place but after a few hours of research, I am a little stumped. BRAND NEW rails 4.2.10 (same ruby) ...
4
votes
1answer
400 views
ArgumentError (A copy of Api::V1 has been removed from the module tree but is still active!)
I have been struggling with this problem for days now. I have an app for which I am building some APIs and the above mentioned error always crashes my app when running for the first time. The error ...
6
votes
1answer
2k views
NoMethodError: undefined method `halt_callback_chains_on_return_false=' for ActiveSupport:Module
I've been developing this RoR 5.1 application for a while, and I need to add a new migration now:
class AddActiveFlagToParameters < ActiveRecord::Migration[5.1]
def change
add_column :...
3
votes
1answer
105 views
Method name is in list returned by Object#singleton_methods but not accessible using Object#singleton_method
I'm confused with the difference between Object#singleton_method and Object#singleton_methods.
I thought that the result in Object#singleton_methods is the true set of !!Object#singleton_method(:name)...
0
votes
1answer
71 views
Ruby 2.5 activesupport ubuntu conflicts with i18n
I wanna run a simple script with made on Ruby, when i try to run it i get the next error.
Traceback (most recent call last):
6: from thread.py:6:in `<main>'
5: from /root/.rbenv/...
1
vote
1answer
207 views
ActiveSupport Conflict when running tests
I am facing a little problem... I was about to start some Kata exercices on Exercism.io
and when I run the tests i have a Gem:ConflictError
/Users/john/.rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/...
1
vote
1answer
247 views
Using method callbacks in plain Ruby class
I have a plain ruby class Espresso::MyExampleClass.
module Espresso
class MyExampleClass
def my_first_function(value)
puts "my_first_function"
end
def my_function_to_run_before
...
1
vote
2answers
27 views
Change the month of a Date object without returning a new date
Is there a way to change the month of a Date object without returning a new object?
Because Date.now.change and Date.now += 1.month return new date objects.
0
votes
1answer
216 views
undefined method `symbolize_keys' after requiring active support.
I am trying to symbolize the keys of a hash in a non rails project. I can see the symbolize_keys method is part of Active Support so I imported the library but it still doesn't work.
Here is an ...
0
votes
1answer
62 views
Why ActiveSupport try() is override when I define a method try with a bang
What a surprise when I defined a method the set my ActiveRecord User attribute currency_code to Turkish lira (TRY).
So in User I defined:
define_method("try!"){ update! currency_code: :try }.
And ...
1
vote
3answers
58 views
Array method versus hashes
I have an object (returned from and API) that is either a hash or an array of hashes. I want to enclose it in an array if it is not already an array.
I tried to apply Array on it, which functions in ...
0
votes
1answer
37 views
humanize NoMethodError on padrino-0.14.1.1
I used padrino-0.14.1.1 and activesupport-5.1.1 in combination and I generate padrino admin app. When I display the login page (/admin/sessions/new) the following error occurred and become 500 error ...
0
votes
0answers
164 views
Rails scaffold not working
In one of my RoR projects, I run "rails generate scaffold project title:string description:text"
on my terminal and here what it throws at me:
/Users/Mika/.rvm/gems/ruby-2.4.0/gems/activesupport- ...
3
votes
1answer
115 views
Parsing timezone abbreviations in DST
I have a service that returns the current time information for various locations which returns timezones using the 3 letter abbreviation format. E.g. EST, PST, EDT, etc. However, which ActiveSupport ...
0
votes
1answer
58 views
Specify UTC Offset instead of timezone to ActiveSupport::TimeWithZone
With ActiveSupport::TimeWithZone I'm able to do the following and get back a TimeWithZone object in the correct timezone.
Time.current.in_time_zone('Alaska')
:> Thu, 19 Oct 2017 08:45:08 AKDT -08:...
0
votes
2answers
70 views
Gem:load error while creating new app in Rails
While creating the new app in rails by rails new projectname Iam getting this error i googled a lot but cant find the solution.
/home/aaquib/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/...
1
vote
1answer
149 views
calling render raises “Undefined method 'logger' for true class”
I'm at a loss trying to figure out what is causing this issue. If I call any variation of render in my controller it raises the following:
NoMethodError: undefined method `logger' for true:TrueClass
...
1
vote
3answers
51 views
Convert active support timezone object in string back to object in rails
How can I convert the active support time object converted to string back to object, In other words, how can I find the active support object from its string?
Example:
a = ActiveSupport::TimeZone....
0
votes
1answer
93 views
Active Record unexpected i18n error
I am building a Ruby project that uses active record but not rails. Inside one of my tests I am trying the following:
it "fails with no driver name" do
command = "Driver"
expect {command_file....
1
vote
1answer
432 views
Rails 5 production error activesupport
i have a 5.0.0.1 project that got problem deploying it. i use capistrano to deploy and it runs puma for me too. puma gets run and "Somthing went wrong" error shows up.
And now i have problem running ...
0
votes
1answer
102 views
rails undefined method at module
i have a method in my rails module, this is my module
module Searchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
...
0
votes
1answer
104 views
How to fix Activesupport compatible versions?
I recently installed the gem "Paperclip" by using:
gem "paperclip", git: "git://github.com/thoughtbot/paperclip.git"
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:...
0
votes
1answer
35 views
Why ActiveRecord::Calculations.maximum return TIme object instead of ActiveSupport::TimeWithZone?
I had a code like this:
Foo.order(:posted_at).last.posted_at
And I learned better way to write it.
Foo.maximum(:posted_at)
But I noticed maximum returns Time object while another way returns ...
0
votes
1answer
77 views
Remove Factory Girl from backtrace
I'm trying to clean up the backtraces I get in my Rails application. Here is the one I'm working on right now:
Failure/Error: attributes_for :bookmark, :invalid
ArgumentError:
Trait not ...
2
votes
2answers
689 views
TypeError: ActiveSupport is not a class
Hello all and thanks in advance for the feedback.
I have a new rails 5.0.4 project (ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin15]) and am having an issue when running my first ...
0
votes
1answer
53 views
What is the quickest way to determine why an integration test failed?
I have the following:
test "should update deal" do
patch user_deal_url(@user, @deal), params: { deal: { name: @deal.name+'xxx' } }
# p @response.body
# p @deal.errors.full_messages
...
0
votes
1answer
21 views
Rails: error when adding two ActiveSupport::Duration objects
In a Rails console (Rails 5.0.1), I have an ActiveSupport::Duration object representing a time interval, in this case 12 minutes:
x = ActiveSupport::Duration.parse("P0Y0M0DT0H12M")
I'd like to add a ...
0
votes
2answers
118 views
Why is Ruby telling me present? is false when a value is there?
I thought
arg.present?
was the truth and the light in order to check whether a string was empty or nil, however I'm noticing a confusing case. If my string is:
arg = "\t"
I get a wrong result:
2....
0
votes
2answers
316 views
How to disable escaping HTML entities in JSON for API, but leave it enabled for views?
config.active_support.escape_html_entities_in_json is enabled by deafult in Rails (v4, v5) and it protects from some XSS attacks by encoding HTML entities <, >, & and it's great for views (...
0
votes
1answer
68 views
start rails server after raspberry reboots
I want my raspberry pi to start a rails server everytime it reboots.
I can start the server without any problems using "rails server".
To start the server after the raspberry pi reboots I put the ...