Rails accessing Desk.com api results in RuntimeError concerning FaradayMiddleware - ruby-on-rails

I was pairing with a coworker, and after writing a feature using the desk.com api, everything was working fine. It was deployed to a staging server, where it too worked fine. However, when I run the code on my local dev machine, when I try to query the api (for example, request all the users on our account), I get a runtime error.
I'm using the desk ruby gem: https://github.com/chriswarren/desk
Here is a session in the rails console:
[1] pry(main)> Desk.users
RuntimeError: missing dependency for FaradayMiddleware::Deashify: undefined method `type' for class `Hashie::Mash'
from /home/rooney/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/middleware.rb:20:in `new'
This is the error I get. I haven't been able to find any info on this error. If anyone needs more info just ask.

Methods "type" and "id" are removed in Hashie version >= 3.4.2
You can fix by rolling back to Hashie v3.4.1

Are you using bundle exec? It's possible that you're using the wrong version of a gem. Try uninstalling versions of the gem other than the one you need.

Related

Ruby on Rails crash during request

I use windows, ruby 2.5, rails 5.1.7, I have a controller with get request, from Unirest or RestClient libs. When I trigger it, the RoR server closes, I see windows error about ruby.
The same request command processed in rails console fine.
That theme was not helped Ruby on Rails server crashes during a HTTPS POST request
UPDATED
Rubymine log error:
Process finished with exit code -1073741819 (0xC0000005)
Controller code:
u = RestClient.get('https://google.com/')
Windows error 0xC0000005 is memory access violation, it means that something is wrong with binaries - most probable native gem extensions or ruby itself,
so try bundle pristine to reinstall gems and if that does not help - cleanup and reinstall ruby.

NoMethodError: undefined method `synchronize' for ActiveRecord::AttributeMethods::GeneratedAttributeMethods

I'm working on a project where we are migrating from an old ruby web api (not rails) that was pulling in activeSupport and activeRecord 4.1.8 and using resque 1.25.2 for jobs to a new rails 4.2.4 project using resque 1.25.2 for job processing as well. Everything has been going pretty smoothly until I started a resque work to process jobs and I got:
NoMethodError: undefined method 'synchronize' for ActiveRecord::AttributeMethods::GeneratedAttributeMethods
This error is only thrown when User.find_by_id or User.new is called within the context of a worker process. This same error is thrown when calling several other models as well but not all of them. Company.new, for example, doesn't throw the error and if I rename the User model to say Companya the error goes away... Running ruby 2.2.3 on the rails app.
Any help would be greatly appreciated.
I guess I've encountered the issue once...
The exception would be raised when Rails failed to find the method that was generated dynamically. So the case I can imagine is that Rails (ActiveRecord) did not define the methods dynamically.
The matters which should be checked are...
restarting resque and KVS.
models' class names, parent classes (should be ActiveRecord::Base) and migration files if that follow Rails naming conventions correctly. See here: http://guides.rubyonrails.org/active_record_basics.html#naming-conventions
reset and migrate again in all environments with the argument like $ bin/rake db:migrate:reset RAILS_ENV=production
stopping the Spring once by $ bin/spring stop. (It restarts automatically when the next bin command is called.)
hmm...Can you use those methods in rails console?
Hope it would help...!
`synchronize' error happens when the related gem is not up to date. I belive if you update your installed gems then the issue would be resolved.

NoMethodError undefined method 'convert_key' when using Mongoid in Ruby 2.2

A project that was working fine has started throwing this error after I upgraded from Ruby 2.0 to 2.2. It happens when I try and access a mongo database, even for a simple Table.all.to_a
NoMethodError (undefined method `convert_key' for {"database"=>"db_name"}:Mongo::Options::Redacted):
Here db_name is the actual name of the database which does exist on the ports configured in mongoid.yml. I'm using mongoid (5.0.0).
How do I resolve this error?
Updated
I printed out a more useful error which traced back to the file:
.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/mongo-2.1.1/lib/mongo/options/redacted.rb:64:
To the code:
def has_key?(key)
super(convert_key(key))
end
alias_method :key?, :has_key?
with a key value of connect.
I'm still not sure why this is happening.
I set the version of mongo in the project gem file to 2.1.0, where previously it had automatically downloaded 2.1.1. I then executed bundler update. This solved the problem. I then switched the version in my gem file back to 2.1.1 explicitly and ran bundler update again. The problem was still fixed! So I guess somehow the mongo gem had been corrupted as I moved the project to rbenv Ruby 2.2.0 from 2.0.0

Rails server crashing in windows without any error in stacktrace

Rails server keeps crashing after a few seconds of starting it.
rails version 2.3.8
ruby version 1.8.7
I'm using windows and Apatana Studio.
There is no error in stacktrace too.
Could you please help me to identify what is causing this issue or suggest me where can I check the same? (eg. any specific logs etc.)
Stacktrace :
=> Booting Mongrel
config.load_paths is deprecated and removed in Rails 3, please use autoload_paths instead
config.load_paths= is deprecated and removed in Rails 3, please use autoload_paths= instead
=> Rails 2.3.9 application starting on
/servers/trunk/main/app/models/market.rb:32: warning: already initialized constant MARKET_CODE_US
I solved this by unstalling SQLite and reinstalling from the command line.
gem uninstall sqlite3
gem install sqlite3
Found the solution here: Rails segmentation fault when starting server?
Error says that you already initialized MARKET_CODE_US in your code. And trying to initialize again in your market model.
Find MARKET_CODE_US in your application direction and remove any unnecessary initialization.
In my case, I was not able to connect to Sybase DB from my application. There were issues with the underlying drivers and I hadn't tested connectivity to DB separately (not using my rails app) using those. But there was a .rb script in the driver folders for testing connection to Sybase from a standalone Ruby code. I used that to diagnose issues. So whenever you are setting up dev env from existing code, just test connectivity to required DB using those drivers separately before plugging them together and then testing.

rails acts_as_state_machine problem

I've installed the restful_authentication plugin. I'm Using rails 2.2.2. However, I can't seem to get past a certain error:
"undefined method acts_as_state_machine"
It doesn't matter if I call db:migrate or script/server, everything results in this same error.
Any ideas?
If you use --stateful or --aasm when you run the generator, it enables acts_as_state_machine support. If that is behavior you want, try installing aasm from the above github link and see if that resolves your issue.

Resources