AWS-SDK Undefined Method presigned_post - ruby

A friend has a project that i'm looking to, to be able to upload a video directly to s3. All the code, all the aws gems, and configurations are the same. My codebase says that presigned_post isn't a method on the bucket object - The S3_BUCKET is defined.
Does anyone know why my S3_BUCKET object simply doesn't have the presigned_post method? It has to be somewhere in configurations or gems i'm thinking but i feel like i've tried everything.
GEM LIST:
aws-sdk (2.8.11, 2.0.6.pre)
aws-sdk-core (2.8.11, 2.0.6)
aws-sdk-resources (2.8.11, 2.0.6.pre)
aws-sdk-v1 (1.66.0)
aws-sigv4 (1.0.0)
fog-aws (0.9.4, 0.9.1)

By updating the gemfile to explicitly say gem 'aws-sdk', '>= 2.6.1' i was able to solve the problem

Related

How to update ruby gem dependency? Must I rebuild it? How?

I have a gem already installed locally, and I wanna add a new dependency into it. I worked with below steps:
Open the gem installation folder as below:
/usr/local/rvm/gems/ruby-2.1.0/gems/nesta-0.10.0
Add new dependency below into gemspec file (nesta.gemspec)
s.add_dependency('stacktracer', '>= 0.0.1')
Append gem 'stacktracer' into Gemfile
Add require "stacktracer" into Rakefile
Run command bundle update nesta
Run command bundle install
Check Gemfile.lock, I already found the new dependency like below:
I have next dependencies:
DEPENDENCIES
debugger
mr-sparkle (>= 0.0.2)
nesta!
rack-test (= 0.6.1)
rspec (~> 2.14.0)
**stacktracer**
test-unit (= 1.2.3)
webrat (~> 0.7.3)
But when I met two problems here:
run command gem dependency nesta, I did not find stacktracer dependency list.
I added require "stacktracer" into app.rb, then run the application, it failed due to below error:
/usr/local/rvm/gems/ruby-2.1.0/gems/nesta-0.10.0/lib/nesta/app.rb:4:in `require': cannot load such file -- stacktracer (LoadError)
Could any one help me to tackle the problems? Is there any approach that could manage to update gem dependency successfully?
You are not supposed to edit the unpacked gems under .../rvm/gems/ruby-2.1.0/gems. If you need to update the alien gem, you are to follow this approach:
Fork the gem source at github
Clone the repo to your local drive
Update whatever you want + update version
Set the dependency in your Gemfile to either use unpacked version or your git:
gem 'nesta', :path => '.../nesta.git'
gem 'nesta', :git => 'git://...'
Don’t forget to eliminate the original gem presence over your system. Hope it helps.

How do I include a commit in a ruby library that hasn't been added to the gem yet?

Specifically, this commit has been merged into mongomapper master to fix a bug that is causing my application to crash:
https://github.com/mongomapper/mongomapper/pull/572
However, it hasn't been released in a new gem. Is it possible to include it prematurely or do I have to wait until it's released? I'm on heroku with a Gemfile.lock that specifies version.
My gemfile.lock currently reads:
mongo_mapper (0.13.0)
activemodel (>= 3.0.0)
activesupport (>= 3.0)
mongo (~> 1.8)
plucky (~> 0.6.5)
I don't know about Heroku, but if you want to use a git version of a gem that is not on Rubygems yet, you must add the git path to your Gemfile.
In your Gemfile change:
gem 'mongomapper'
To:
gem 'mongomapper', :git => 'https://github.com/mongomapper/mongomapper.git'
Or if you're on a more modern ruby, you can also use:
gem 'mongomapper', github: 'mongomapper/mongomapper'
And of course after that you must run bundle install or bundle update mongomapper.
Since the Ruby code isn't compiled, if you have the notes for that patch you can always manually add those changes to the lib directory of the mongomapper gem, although I can't advise against this enough - it's undesirable to change the source code, especially underneath an installed gem.
Once you go down this road you can't really count on any support for related issues until you are updated to a newer version or reverted to the original files.

Ruby Builder conflict

I have a small ruby app that has been working. I am now getting a conflict error with builder. It looks like I updated my gems and now it is conflicting. I have it set in the Gemfile to use v2.1.2. But that is not working either. Thanks for any help you can give me.
Gemfile
gem 'builder', '2.1.2'
Bundler output
$ bundle
Using builder (2.1.2)
Using bundler (1.2.3)
$ bundle show builder
/Users/covard/.rvm/gems/ruby-1.9.3-p327/gems/builder-2.1.2
Conflict message
`raise_if_conflicts': Unable to activate actionpack-3.2.11, because rack-1.5.0 conflicts with rack (~> 1.4.0), builder-3.1.4 conflicts with builder (~> 3.0.0) (Gem::LoadError)
Figured out what my problem was even though I had my Gemfile I wasn't using it. Since rails handles that automatically I didn't know I had to add a require to use it. After adding this to my ruby files it worked perfectly.
require "bundler/setup"

Faraday conflicts in google_drive and google-api-client

I'd like to be able to use both the google-api-client gem to do service to service authentication and the google_drive api to access spreadsheets. Unfortunately, these gems seem to conflict due to requiring different versions of Faraday in their dependencies. Anyone know how to solve this?
Error if google_drive is required first:
specification.rb:1637:in `raise_if_conflicts': Unable to activate google-api-client-0.4.4, because faraday-0.8.1 conflicts with faraday (~> 0.7.0) (Gem::LoadError)
Error if google/api_client comes first:
specification.rb:1637:in `raise_if_conflicts': Unable to activate oauth2-0.7.1, because faraday-0.7.6 conflicts with faraday (~> 0.8) (Gem::LoadError)
Give me an day or so and I'll update the google-api-client gem to use the more recent version of Faraday.
That said, you shouldn't need a separate gem to use Google Drive, and any gem designed to add syntactic sugar to a discovery based Google API should really be using the official gem as a base.

Twitter entities no longer recognized in ruby script

I have a ruby script that scans each type of entity in a given tweet:
status = Twitter::Client.new.status(tweet[:id_str], {:include_entities => "1"})
status[:entities].each do |x|
#job on the entity
end
It was doing good until yesterday. Now I get NoMethodError: undefined method 'entities' for #<Twitter::Status:0x000001033e1800>
I can't figure it out since I've checked that status does include entities after the first line.
Any clues?
EDIT: turns out it's the new version of the twitter gem (v2.0.0) which is in cause. First I'd like to downgrade it to the last version working (v1.7.2), but I'm getting an annoying gem version error:
Bundler could not find compatible versions for gem "hashie":
In Gemfile:
topsy (~> 0.3.6) depends on
hashie (~> 1.0.0)
twitter (= 1.7.2) depends on
hashie (1.1.0)
How can I work it out?
If you need specific gem's version, you can forcely set it throught Gemfile:
gem "rack", "1.0.1"
gem "rails", ">=2.3.2"
In the end it was a conflict in the Gemfile:
gem 'topsy', '~> 0.3.6'
gem 'twitter', '1.7.2'
were requesting different versions of hashie, so I just deleted the version of topsy and it worked.

Resources