How do I solve NoMethodError with google_drive gem? - ruby-on-rails

Im trying to create an web app that reads from a spreadsheet in my google drive. But when Im done with the Oauth2 procedure and wants to list the files I get this Error:
NoMethodError: undefined method `drive' for nil:NilClass
from /Users/administrator/.rvm/gems/ruby-2.2.0/gems/google_drive-1.0.0/lib/google_drive/session.rb:101:in `drive'
from /Users/administrator/.rvm/gems/ruby-2.2.0/gems/google_drive-1.0.0/lib/google_drive/session.rb:149:in `file_by_id'
from /Users/administrator/.rvm/gems/ruby-2.2.0/gems/google_drive-1.0.0/lib/google_drive/session.rb:186:in `spreadsheet_by_key'
from (irb):21
from /Users/administrator/.rvm/rubies/ruby-2.2.0/bin/irb:11:in `<main>'
Im using Rails 4.2.0 with ruby 2.2.0

client_or_access_token argument is nil. Look at this code.

Related

After Rails Upgrade to 5.2 and ruby to 2.5.7 getting undefined method `prepend' for #<HTTP::Client error in my rails project

After rails upgrade to version 5.2 and ruby to 2.5.7 I am getting below error in my rails project
I have upgraded faraday gem as well but not able to solve this.
Any help is appriciable.
NoMethodError: undefined method `prepend' for #<HTTP::Client:0x00007ff4dc21a470> Did you mean? present?
https://www.rubydoc.info/gems/httpclient/2.7.1#features
Select the "Methods" link in the top left
Search for 'prepend'
There is no such method. There is a literal bug wherever this line is being called. You haven't pasted the stack trace, but below this error, there is probably a line about which file and what line in that file is responsible for this error. You should change the code in that file (if it's code you authored) or you should stop using whatever library is causing this line to be called.

Global error handler for specific case. Undefined method 'public_url'

ruby '2.5.1'
rails '5.1.7'
My project is for sound management. All uploaded files are in the cloud storage - sounds/sound images/album images and etc.
But some files on cloud storage are absent. And for following code in view:
.row
- #sounds.each do |sound|
.col-md-2
.play{ "image-src": "#{sound.image.url(:small)}", style: "background: url(#{sound.image.url(:small)});" }
I get following error:
ActionView::Template::Error (undefined method `public_url' for nil:NilClass)
There are a lot of such cycles (#sounds.each) in the project, so I would not want to rewrite each one.
How to write an error handler for such case? So that in absence of files in storage, sound is skipped.
Maybe there is a way to write code in application_controller.rb or something similar?
I use gem 'carrierwave-google-storage' for images and gem 'google-cloud-storage' for attachment.
It seems that there are some cases where the error ActionView::Template::Error (undefined method `public_url' for nil:NilClass) occurs.
Looking on the Community, it seems that there are some options/ways that can fix this error and it would depend on the way that your code and application is configured. For this reason, I would recommend you to take a look at the following posts and answers, to check if they help you. :)
ActionView::Template::Error: ActionView::Template::Error: undefined method `[]' for nil:NilClass
Railstutorial ActionView::Template::Error: undefined method `email' for nil:NilClass
Ruby on rails : undefined method `map' for nil:NilClass , what causes this? when i add record to table
Let me know if the information helped you!

undefined method `reject' for false:FalseClass in Carmen::Country.named("Libya").subregions?

I'm using rails version 5.1.5 and Carmen, and when I do:
Carmen::Country.named("Libya").subregions?
in the rails console, after including carmen succesfully, I get this error:
"NoMethodError: undefined method `reject' for false:FalseClass"
But for other countries it works fine. For example:
Carmen::Country.named("United States").subregions?
returns true. What am I doing wrong?
The issue was with an empty file in the yml data for subregions, in the gem folder. carmen-1.0.2/iso_data/base/world/ly.yml.

Issue with Dalli not working as expectd?

I have a simple rails app and I am trying to save and retrieve keys from a memcache box, which was working for a long time unless we started encountering the error below, I have tried debugging this but will need someone to help now
[2015-10-28 12:25:46.649][ERROR] Unexpected exception during Dalli request: NoMethodError: undefined method `<<' for nil:NilClass (pid:58452)
[2015-10-28 12:25:46.649][ERROR] /Users/aupadhyay/.rvm/gems/ruby-2.2.2/gems/celluloid-0.17.2/lib/celluloid/proxy/async.rb:28:in `method_missing'
/Users/aupadhyay/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/core_ext/marshal.rb:6:in `load'
Let me know incase anyone has insights to this ?

Squeel working in Rails Console but not in Controller. Error: undefined method `method' for nil:NilClass

I'm using Squeel, and I have an odd problem. The following line runs just fine in Rails Console, but gives an error when run in the model's controller!
Issue.joins{property.users}.where{property.users.id == 1}
Issue belongs_to Property, and Property has_and_belongs_to_many Users. I'm trying to load all the issues associated with the user_id == 1.
I get the error: "undefined method `users' for nil:NilClass" when I run the line in the IssuesController, but it works in Rails Console. What's wrong?
P.S. I'm running Rails 4.0.3, Ruby 2.0.0, and Squeel 1.1.1
Try this
my_properties = Property.where{user_id == 1}.select{issue_id}
Issue.where{id.in(my_properties)}

Resources