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.
Related
I got this error
NameError in WelcomeController#index
uninitialized constant YouTubeIt
Rails.root: C:/Sites/rails_code/youtube
Btw i checked the gem author github, checked sintax of constant, seems everything's alright, so i can't figure it out.
There is a very similar question here:
Uninitialized constant SO
But in his case, there was a typo, i don't have any typo, i even checked the tutorial like 6 times, but there's no apparent error on my side, here's my controller code:
class WelcomeController < ApplicationController
def index
#cliente = ::YouTubeIt::Client.new(:dev_key => "AI39si4Ao5BFsYIkbzko7b9A_iktB2Pc8DAblJJ_JzJx6IL6Mju1dYYkMKY6TByz8MJPXfm4__tCAt9Is6Mvjg2JM55kuJVVqQ")
#videos = #cliente.videos_by(user: "AlbertoMaso2")
end
end
already installed the youtube_it and declared it's presence in the app by adding it to the Gemfile.
I'm stuck on this one and can't get it to work.
Anyone can shed some light upon this?
Thanks in advance!
When you have changed Gemfile, or added a new gem to it, please, make sure that you have updated Gemfile.lock also. To update lock file just run bundle install command.
Then in order to check usability the gem, you could not run whole rails server, but simply rails console with loaded development environment. Do it as follows:
$ rails c
or
$ rails console
Then inside the IRB, you can try your new gem features, in your case as follows:
irb(main):001:0> require 'youtube_it'
=> true
irb(main):002:0> YouTubeIt
=> YouTubeIt
What happens if you change
#cliente = ::YouTubeIt::Client.new...
to
#cliente = YouTubeIt::Client.new...
On a server i had an installation of the gollum wiki. It ran fine. Now I also had to install redmine on that same server. This was a big pain, as redmine refused to run with puma. I had to mess around a lot with different gems to make it work at all.
But for some reason i now get an error from gollum, whenever i try to create a new wiki page:
NoMethodError at /create/old/git-tips
undefined method `translate' for I18n:Module
The stack trace shows that the error occurs in this line of stringex:
/var/lib/gems/1.9.1/gems/stringex-2.0.5/lib/stringex/localization/backend/i18n.rb in i18n_translations_for
::I18n.translate("stringex", :locale => locale, :default => {})
So i checked the installed packages with gem list and the required version of i18n 0.6.1 is there.
Any idea, what could be wrong and how to fix this?
For reference here's the output of gem list.
This may or may not help, but I had a similar problem on a large code base where there was an application-specific I18n module (which included some custom helper methods), but this was overriding the 't' method (a shortened form of translate).
In this case I found I could force the base-level I18n module by using two colons...
::I18n.t('thing')
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'
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
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.