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')
Related
We are getting this error on all local setups of our project(currently) when we call any method like:
belongs_to :abc
after_create :some_method
def some_method
if self.abc.saved_change_to_parent_id?
...
// or even self.abc.parent_id_before_last_save
end
It gives:
NameError (undefined local variable or method `first' for ActiveRecord::NullMutationTracker:Class):
app/models/model_name.rb:50:in `some_method'
Yes, there is not a full trace with rails internal file paths etc, i only get my project files trace. Maybe its some logger config issue, any help to get full trace will also be appreciated.
There are no such issues i could find on internet, thats why posting here.
PS: Not posted on rails issue tracker(github issues) because i don't have minimal reproduction.
Stack
ruby: 2.4.3
rails: 5.1.5 (also tried on 5.1.7)
OS: Ubuntu 20, also tried on macOS
Thanks in advance.
UPDATE1: Using byebug, i got to this trace, where error is occuring:
/Users/dev/.rvm/gems/ruby-2.4.3/gems/acts_as_singleton-0.0.8/lib/acts_as_singleton.rb:43
which is here, so it is not directly from rails, but a very outdated gem we have in our code for some reason.
As i posted in the update, issue was not with rails or anything, i used byebug to track trace and it was something like:
activemodel-5.1.5/lib/active_model/attribute_methods.rb:384
activerecord-5.1.5/lib/active_record/attribute_methods/dirty.rb:146
activerecord-5.1.5/lib/active_record/attribute_methods/dirty.rb:319
activerecord-5.1.5/lib/active_record/attribute_methods/dirty.rb:315
acts_as_singleton-859f49112c03/lib/acts_as_singleton.rb:43
The last line, should not be there, as we are not using acts_as_singleton on any of the involved models.
So after some tracking, it turned out issue with the gem. I have created a fork and used that fork. Here is the fork: https://github.com/ziaulrehman40/acts_as_singleton (forked it from another fork, which seemingly had some other fixes as well). And you can see my changes here.
What was the issue?
This gem writes a module named Singleton within ActiveRecord module. Which seems ok, unless you realize that there is another module named Singleton already. Whihc is being included in:
gems/activerecord-5.1.5/lib/active_record/attribute_mutation_tracker.rb:83
class NullMutationTracker # :nodoc:
include Singleton
...
So as you can see, this Singleton module gets overriden(or expanded, not sure) un-intentionally by that outdated gem(acts_as_singleton).
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.
I've created a gem called kmdata that has an executable. When running bundle exec kmdata decot.7 from within my gem's folder everything works fine. After releasing the gem to rubygems I ran gem install kmdata (in a new window). I then tried to run kmdata decot.7 and I get the following
/Users/kyledecot/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:891:in `connect': undefined method `set_params' for #<OpenSSL::SSL::SSLContext:0x007fff31d59d18> (NoMethodError)
from /Users/kyledecot/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from /Users/kyledecot/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:851:in `start'
from /Users/kyledecot/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1367:in `request'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p247/gems/kmdata-0.0.3/lib/kmdata.rb:24:in `get'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p247/gems/kmdata-0.0.3/bin/kmdata:5:in `<top (required)>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p247/bin/kmdata:23:in `load'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p247/bin/kmdata:23:in `<main>'
The line in lib/kmdata.rb is
response = http.request(Net::HTTP::Get.new(path))
Update #1
This only appears to be an issue when using 2.0. If I run the same command in 1.9.3 then everything works as expected.
You likely need to include this line (e.g., at the beginning of your file):
require 'openssl'
I had this error on 2.0, and adding this line fixed it. Maybe your 1.9.3 has some configuration/gem that implicitly requires that?
Just out of the blue, but have you configured Net::HTTP to use an SSL connection?
Using Net::HTTP.get for an https url
Here's another person having the same problem...no mention that it's a solution, but try it out: https://www.ruby-forum.com/topic/4417738
This looks like an error in Net::HTTP...are you using the most recent version of the gem?
If I were you, I would focus on:
undefined method `set_params' for #<OpenSSL::SSL::SSLContext:0x007fff31d59d18> (NoMethodError)
I think you could have your gems organized in such a way that there's either something not being included, or you have two classes or methods with the same name, and the wrong one is now being chosen.
I've had something like this happen a couple of times.
Simply put, it's probably going to end up being a scope thing - a require / include, or a duplicate method.
If I'm right, there's not much we can do to help - without access to your computer.
I hope you find it. I would recommend doing some grepping/searching through files for method names, class names etc. if you haven't already.
Edit:
looking back, it seems like you're just dealing with stock code.
If that's the case, try uninstalling all versions of ruby, and then re-installing 2.0.0. You'd be surprised - I've had 1.9.3 do something like this when they are both installed.
I am working on an established project, Rails 3, and trying to turn of SSL in development. The following line in environments/development.rb generates an error.
config.after_initialize do
SslRequirement.disable_ssl_check = true
end
Error reads:
undefined method `disable_ssl_check=' for SslRequirement:Module (NoMethodError)
Any pointers to this?
Searches have revealed little so far.
Thank you
Based on the version number you provided (0.1.0) the problem is likely caused by the fact that you are using a different gem.
The one you use is ssl_requirement (repo), whereas the disable_ssl_check method is provided by bartt-ssl_requirement (repo). The latter one is actually a fork of the former one so you might try to upgrade.
I'm upgrading my Rails app to work with Ruby 1.9 and I keep encountering errors like this:
Anonymous modules have no name to be referenced by
/home/foo/.gem/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:585:in `to_constant_name'
/home/foo/.gem/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:391:in `qualified_name_for'
/home/foo/.gem/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:104:in `rescue in const_missing'
/home/foo/.gem/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:94:in `const_missing'
/home/foo/app/config/environment.rb:66:in `block in <top (required)>'
etc.
Google finds all kinds of hits for this, but each of them pertains to a specific fix for one specific gem or app. None of them explain what the message really means.
What is an "anonymous module"?
Where is this error message coming from? (The Ruby interpreter itself?)
What is different about Ruby 1.9 that causes this? (Rails 2.3.8 with Ruby 1.8.7 does not encounter this.)
What is the general/proper way to fix this error?
Line 66 of environment.rb is the configuration for super_exception_notifier (old version, 2.0.8):
ExceptionNotifier.configure_exception_notifier do |config|
config[:sender_address] = %("Foo" <foo#foo.com>)
config[:exception_recipients] = %w(foo#foo.com)
config[:skip_local_notification] = false
end
From what I can tell, ExceptionNotifier is undefined, and ActiveSupport is trying to magically load it, but fails and then fails again trying to print a nice error message.
An anonymous module is a module that is declared like so:
Fred = Module.new do
def meth1
"hello"
end
def meth2
"bye"
end
end
instead of by using the regular Module mod_name <block> syntax. Since they have no module name, you can't retrieve the module name. to_constant_name is attempting to call desc.name.blank? where desc is an anonymous module (with no name).
This error is coming from the ActiveSupport module, which may indicate a bug in the active_support gem or may indicate that some other piece of code is using ActiveSupport incorrectly. The error message alone doesn't give enough information to identify the culprit (to me at least, someone with more rails experience might be able to provide more insight).
Without knowing the offending code it's also hard to say exactly why this error is popping up with 1.9, or what needs to be done to fix it. Considering that there are a lot of un- and under-maintained gems out there that have not been updated for 1.9 yet, I would suspect that ActiveSupport is not the source of the problem. Upgrade all of your gems that have 1.9-compatible versions, and then try disabling your other gems one at a time (if you can) and see if you still get the error.
If you provide a list of the other gems that you are using, someone else who may have encountered the error before may be able to provide some details.
This may happen if you try to exploit ActiveRecord's internal class and module contexts in the wrong way. I had this error yesterday while working on a gem which extends deep inner workings of ActiveRecord. I finally managed to get around this problem by redesigning my code which exploits the inner contexts. It would be interesting to see the surrounding lines of environment.rb:66 for further analysis.
This may happen when the class name doesn't match the filename, in
my case it was a file named application.rb contaning the ApplicationController
class. Renaming the file to application_controller.rb solved the problem.
When I got this error, it was due to a misspelling while defining a class. If you are getting this error, it may be worth examining your module and class definitions for typos.