My code:
require 'rubygems'
require 'basecamp'
basecamp = Basecamp.establish_connection!('example.basecamphq.com', 'example', '123456', true)
projects = Basecamp::Project.find(:all)
projects.inspect
It gives:
/Users/kir/.rvm/gems/ruby-1.8.7-p352#project/gems/activeresource-3.1.0/lib/active_resource/base.rb:922:in `instantiate_collection': undefined method `collect!' for #<Hash:0x105faa450> (NoMethodError)
from /Users/kir/.rvm/gems/ruby-1.8.7-p352#project/gems/activeresource-3.1.0/lib/active_resource/base.rb:894:in `find_every'
from /Users/kir/.rvm/gems/ruby-1.8.7-p352#project/gems/activeresource-3.1.0/lib/active_resource/base.rb:806:in `find'
from bs.rb:4
What's wrong with my code?
There were some problems with the basecamp wrapper gem and rails >= 3.1.x. The "undefined method `collect!'" error was one of them. I pushed some fixes and bumped the gem version to 0.0.7 which should solve that and other problems.
Related
I'm doing a Ruby training on Codewars and I'm stuck on something.
I have to do this :
list([ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Maggie'} ])
# returns 'Bart, Lisa & Maggie'
So I tried this code:
def list names
names.map(&:values).flatten.to_sentence(last_word_connector: ' &')
end
But unfortunately, I have this error :
main.rb:4:in `list': undefined method `to_sentence' for ["Bart", "Lisa", "Maggie", "Homer", "Marge"]:Array (NoMethodError)
Did you mean? to_set
from main.rb:6:in `<main>'
I've been searching for hours and I don't understand why 'to_sentence' doesn't work...
Thanks.
Array#to_sentence is an ActiveSupport method. ActiveSupport is a Ruby gem that adds a lot of useful utility methods to existing classes. You'll need to install and require the gem to make sure it's loaded
gem install activesupport
Then, at the top of your file,
require 'active_support/all'
If you're writing a Rails project, then you get ActiveSupport for free. But if you're writing standard Ruby, you have to require it.
I am trying to implement the payola-payment subscription in a Rails project.
I have tried to use the gem payola-payments but after running bundle, I am facing the following error when running rake db:migrate:
NoMethodError: undefined method `event_retriever=' for StripeEvent:Module
Did you mean? event_filter=
I have found a solution that suggests using gem 'payola-payments', :git => 'git#github.com:payolapayments/payola.git', but after that I get a migration error:
NoMethodError: undefined method `[]' for #
Can any one help with this?
Your version of payola-payment has a bug check it here :
github.com/payolapayments
It is suggested to replace
gem 'payola-payments'
with
gem 'payola-payments', :git =>
'git#github.com:payolapayments/payola.git'
in you Gemfile.
I have a Sinatra app that uses Activerecord gem. Everything used to run well until some moment my code just stopped working. The only thing that I did in between is update my Gemfile with bundle update.
Now this code:
require 'sinatra'
require 'sinatra/activerecord'
set :database_file, "../../config/database.yml"
raises /home/username/.rvm/gems/ruby-2.1.5/gems/sinatra-activerecord-2.0.3/lib/sinatra/activerecord.rb:32:in database_file=: private method 'load' called for Psych:Module (NoMethodError).
I tried to rollback to previous Gemfile.lock version, but error persisits.
What should be my next steps?
Setting
set :database, {adapter: 'postgresql', database: '_your_database_name_'}
instead of
set :database_file, "../../config/database.yml"
helps, but I'm still not sure where the bug came from.
Just pulled latest code and now getting:
...my_app/Gemfile:2:in `evaluate':
undefined method `ruby' for #<Bundler::Dsl:0x007fc17c3fc6c8> (NoMethodError)
The ruby method that allows you to specify the version of Ruby your project should use was only added in Bundler 1.2. You’ve got a project with a Gemfile that uses this new ruby method, but have an old version of Bundler. You just need to get Bundler 1.2 with
gem install bundler
and you should be good to go.
I am writing a script with Ruby/MongoDB that stores Tweets. After I gem-installed mongoid, this first-steps code throws an error:
require 'rubygems'
require 'mongo'
require 'mongoid'
Mongoid.database = Mongo::Connection.new('localhost').db('db')
# snippet from http://rujmah.posterous.com/using-mongoid-without-rails
NB. This is no Rails app, but a Terminal script.
The error I get is:
./mongoid.rb:10: uninitialized constant Mongoid (NameError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from mongoid.rb:3
It works in irb and I'm running ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0].
What am I doing wrong?
Edit August 2012
Somehow I got it to work. Alas, nearly a year on, I really can’t remember how. I will try to do better next time.
I hit the same issue while trying to get Bullet gem to work. The solution for me was to simply move gem 'mongoid', github: 'mongoid/mongoid' as the first line of the Gemfile. I find it really odd but that was how I got rid of that error.
I am using Ruby 2.1.0 and Rails 4.0.0