NameError (uninitialized constant ActiveStorage::Downloading) - ruby-on-rails

I am running Rails 6.0.3.2 and ruby 2.6.6
I am trying to use the ActiveStorage::Downloading class but can't figure out how to get it to load!
I am getting the error
irb(main):001:0> include ActiveStorage::Downloading
Traceback (most recent call last):
1: from (irb):1
NameError (uninitialized constant ActiveStorage::Downloading)
I'm pretty sure this is me, but I can't figure it out. I am using ActiveStorage already in the project, but want to use the download_blob_to_tempfile method.

First, load the library by using require and include to use the methods of that module.
require 'active_storage/downloading'
include ActiveStorage::Downloading

Related

ArgumentError in FactoryBot build method in Ruby On Rails

Good morning all,
I am following an online course from Udemy, in the latter portion of the course, we learned to use FactoryBot. At this moment, I'm having an error in irb on FactoryBot.build(:book) method
irb(main):001:0> FactoryBot.build(:book)
Traceback (most recent call last):
1: from (irb):1
ArgumentError (missing keywords: from, to)
I don't find out why, because, first of all, I followed the course to the letter (I came back to it several times). Secondly, I have the same version as the trainer:
2.5.1

How can I find a definition true_user for Rails app using devise gem?

After Rails 5.2 and ruby 2.6.5 upgrade, I am getting errors: (1) NameError: uninitialized constant UserUploader::Uploader and (2) ArgumentError undefined class/module UserUploader::Uploader when calling true_user within app/controllers/application_controller.rb.
Where can I find a definition of method true_user (I couldn't find any source for this method in the web)?
I am not seeing the relationship with true_user call and class UserUploader < ImageUploader.

How to resolve Rails, GeoRuby (and postgis/postgresql): NameError: uninitialized constant Point?

when i am running the code on rails console as:
Point.from_x_y(88.365805,22.543538)
Then getting error as:
NameError: uninitialized constant Point
Can anyone help me to remove this error?
I am running require 'gems' before running this code as:
require 'geo_ruby'
require 'geo_ruby/ewk'
It's namespaced, so if you're using it rails instead of pure ruby, you need to call the full namespace of the class. Your query will work if you call instead:
GeoRuby::SimpleFeatures::Point.from_x_y(88.365805,22.543538)

Log full stacktrace in rails including all gems

Currently when I look in the log files of my rails application I get stacktraces like:
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/concerns/example.rb:192:in `rescue in create_example'
app/controllers/concerns/example.rb:163:in `create_example'
app/controllers/concerns/example.rb:11:in `example'
app/controllers/example_controller.rb:39:in `create'
The error is triggered from a second project which is included as gem.
On line 192 in the example.rb (concern) we use some classes from that included gem and in that class the real exception occurs.
Another example:
ZeroDivisionError (divided by 0):
app/controllers/dummy_controller.rb:15:in `index'
And on line 15
test_object.divide_by_zero
test_object is an instance of a class defined in the included gem
I want rails to display and log the full stacktrace including all or specific gems but I can't figure out how to do this. Does someone know how to do this? or someone that can give me a push in the right direction?
Thanks!!!
It's used like this:
Rails.backtrace_cleaner.remove_silencers!
Depending on what version of rails you are using this may help:
http://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html#method-i-remove_silencers-21

Can't create users in rails when using authlogic because of cookies

So, I have a standard rails 3 app with authlogic. If I'm not in the browser (in the console or in the test environment), I can't create user models.
For example:
I have this code either in a rspec test or in my console:
user = User.create(...user attributes...)
And I get this error:
NoMethodError: undefined method `cookies' for main:Object
I've looked all over the internet and can't figure this out. Any help would be greatly appreciated.
EDIT:
So, I looked around some more and found in the documentation to do this:
include Authlogic::TestCase
but then I get this error:
uninitialized constant Authlogic::TestCase
I had this same exact problem. Where in your application did you put the following line:
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
I ran into this error when I placed the line in either the environment.rb file or within a file within my initializer folder.
I eliminated the problem when I placed the line in my ApplicationController instead.

Resources