uninitialized constant ActiveSupport::SecureRandom - ruby-on-rails

I'm having this strange error for the devise_invitable extension:
uninitialized constant ActiveSupport::SecureRandom
But the strange thing is that I don't know how to load that module anyway, like if in my console I execute ActiveSupport, thats fine and responds with true but not that SecureRandom class, or ActiveSupport::SecureRandom, and like I know its part of ActiveRecord, it's in the docs here: http://api.rubyonrails.org/classes/ActiveSupport/SecureRandom.html
How would you start troubleshooting an issue like this?
More Details
So it seems the class SecureRandom works as is, but not when called as part of ActiveSupport like ActiveSupport::SecureRandom, why would this be?

I fixed this by switching to the master branch of Devise on my 3-1-stable Rails application.
gem 'devise', :git => "git://github.com/plataformatec/devise"

I ran into this issue with the activeadmin gem and solved it with a hack at the top of devise.rb
ActiveSupport::SecureRandom = SecureRandom
Source: http://coderwall.com/p/fttpra

Related

ApiAuth gem + ActiveResource

I'm trying to get ApiAuth working with ActiveResource and having no luck. The documentation suggests this as the way to use the gem:
class Foo < ActiveResource::Base
with_api_auth("foo", "bar")
end
This results in the following error:
NoMethodError: undefined method `with_api_auth' for Foo:Class
I know that the api_auth library is available because when I do
require 'api_auth'
i get "false", which I believe means that the library/gem was already loaded.
Additionally, I picked out the module/class where with_api_auth is defined and don't get an error:
2.3.8 :004 >
ApiAuth::Rails::ActiveResourceExtension::ActiveResourceApiAuth
=> ApiAuth::Rails::ActiveResourceExtension::ActiveResourceApiAuth
2.3.8 :005 >
I found a couple issues for this exact error on the api_auth github project, but neither had solutions that worked for me.
Anyone else see this error or know how to eliminate it?
So in the end it was an ordering of gems in my Gemfile that made the difference. It ended up being an ordering issue in my Gemfile. I found an issue (113) on the gem github issues list that said to make sure the order was right by doing:
gem 'activeresource'
gem 'api-auth'
Originally this hadn't worked and it ended up being because you no longer have to explicitly put activeresource in your Gemfile. So I moved gem 'api-auth' the last line in my Gemfile and everything worked.
I don't know for sure, but I think it has to do with how mixins are loaded on bundle install. "think" being the most important word in that statement.

Rails public_activity gem rspec setting error

I am integrating public_activity (version 1.5) gem to my Rails 4 app.
Trying to set up tests as specified in their wiki, I write the following:
#spec_helper.rb
require 'public_activity/testing'
PublicActivity.enabled = false
However, trying to run my specs I get the following error:
/my_app/spec/spec_helper.rb:24:in <top (required)>': undefined methodenabled=' for PublicActivity:Module (NoMethodError)
Looking at Public Activity module source code I can clearly see enable= method there.
Can you please advise me what am I doing wrong here?
Looking at the source, testing.rb does not require PublicActivity where enabled= is defined, so I believe you'll need to do
require 'public_activity'
require 'public_activity/testing'
like it's done in their test_helper.rb.
The documentation seems to be incorrect.
I was able to get it to work like this:
PublicActivity::Config.instance.enabled = false
Update: Jan Klimo's answer is the correct way.

undefined method `debug' for nil:NilClass

for a couple of days, I've been having following issue:
in all my models, i get "undefined methoddebug' for nil:NilClass"` when it runs
logger.debug "whatever"
Adding Rails. in front of logger.debug solves the issue but I'd like to find the cause.
I have no clue where to search. I'm running rails 3.2.8 and the only gem I recently installed is friendly_id
thanks.
The problem is due to the fact that I added the actionview helpers in my model:
include ActionView::Helpers
I don't know the reason but it's the cause...
To avoid having to add Rails in front of all my logger lines, I then added this line in the models having the Helpers included:
logger = Logger.new(STDOUT)

Cannot find gem in controller

I'm sure this is an easy question but I'm having a hard time figuring out what to Google.
I'm trying to use the library ChunkyPNG.
I added it to my Gemfile and did a bundle install.
bundle list | grep "chunky"
* chunky_png (1.2.5)
So far so good.
I try using it in my controller:
image = ChunkyPNG::Canvas.from_data_url(params[:data]).to_image
(The docs for this method are available here)
It results in the following error:
NameError in MyController#create
uninitialized constant MyController::ChunkyPNG
Why is prepending the controller namespace? I imagine that's what is causing the error.
Otherwise, it means that ChunkyPNG is not install (and it clearly is).
Am I not able to use this gem upfront without writing some sort of rails plugin to wrap around it?
Thanks
EDIT:
Question has been answered, see #apneadiving's comment
In your controller, or somewhere else in the app do:
require 'chunky_png'

uninitialized constant ThinkingSphinx::Deltas::DelayedDelta

I'm attempting to get Thinking Sphinx working w/ Delayed Jobs but I am not having any success. I keep getting the following error:
uninitialized constant ThinkingSphinx::Deltas::DelayedDelta
I have thinking-sphinx (2.0.2), delayed_job (2.1.3), and ts-delayed-delta (1.1.1) installed. I have restarted sphinx using rake ts:restart. I don't really know what else to try. Any suggestions?
Hey Kyle, I'm using the exact same stack with no problems whatsoever.
Please, make sure you have something like this in your Gemfile:
gem 'ts-delayed-delta', '1.1.1', :require => 'thinking_sphinx/deltas/delayed_delta'
If that doesn't help it'd be nice if you provided us with some more context. Backtrace would be nice.

Resources