can`t get the simplest twitter4r setup to work in rails

0 views
Skip to first unread message

mtin79

unread,
Aug 21, 2009, 8:08:27 PM8/21/09
to twitter4r-users
hey out there!
i`d love to user twiter4r to get the timeline for my twitter account.
unfortunatelly i am hanging with this error for quite a while now :

ArgumentError (wrong number of arguments (1 for 0)):
app/controllers/site_controller.rb:7:in `initialize'
app/controllers/site_controller.rb:7:in `new'
app/controllers/site_controller.rb:7:in `index'
haml (2.2.2) lib/sass/plugin/rails.rb:19:in
`process_without_compass'
/Library/Ruby/Gems/1.8/gems/chriseppstein-compass-0.8.10/lib/compass/
app_integration/rails/action_controller.rb:7:in `process'

--------------------------------------------------------------------------------------------------------------
app/site_controller.rb

require "twitter"
require "twitter/console"

class SiteController < ApplicationController

def index
twitter_client = Twitter::Client.new(:login =>
'weloveulm', :password => 'ms!79Mtwi')
@timeline = twitter_client.timeline_for(:me)
end

end


gems are installed as far as i know. any ideas? a current example of
how to setup twitter4r in rails would be great. cheers!


Susan Potter

unread,
Aug 22, 2009, 12:41:49 AM8/22/09
to twitter4r-users
Please uninstall the twitter gem!:)

mtin79

unread,
Aug 22, 2009, 5:59:56 AM8/22/09
to twitter4r-users
hey susan,
what exactly do you mean with the twitter gem? the twitter4r gem or
another one? in my gem list i got the following:

.
.
treetop (1.3.0, 1.2.6)
twitter4r (0.3.1)
tzinfo (0.3.14, 0.3.13)
.
.


or is my Rails::Initializer setup wrong?

Rails::Initializer.run do |config|
config.gem 'twitter4r', :lib => 'twitter'
.
.

mtin79

unread,
Aug 22, 2009, 6:17:38 AM8/22/09
to twitter4r-users
ok so there might be a collision as i found this gem as well in my
list:

mbbx6spp-twitter4r (0.4.0)

so what i did next was to delete the regular twitter4r gem (twitter4r
(0.3.1) ) and changed my environment.rb to: config.gem 'mbbx6spp-
twitter4r', :lib => 'twitter' .

still the same error...

S Potter

unread,
Aug 22, 2009, 6:08:47 PM8/22/09
to twitter...@googlegroups.com
Oh dear, I misread the stack trace. What version of Ruby are you running?
--
mailto:m...@susanpotter.net
blog:http://geek.susanpotter.net
blog:http://startup.susanpotter.net
linkedin:http://www.linkedin.com/in/susanpotter

mtin79

unread,
Aug 23, 2009, 7:45:40 PM8/23/09
to twitter4r-users
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]

S Potter

unread,
Aug 23, 2009, 10:58:31 PM8/23/09
to twitter...@googlegroups.com
Ok, looking at the stack trace it definitely looks like it is loading
a class called Twitter::Client which has an intialize method that
doesn't take any arguments instead of the twitter4r gem version of the
class.

>> > > ArgumentError (wrong number of arguments (1 for 0)):
>> > > app/controllers/site_controller.rb:7:in `initialize'
>> > > app/controllers/site_controller.rb:7:in `new'
>> > > app/controllers/site_controller.rb:7:in `index'
>> > > haml (2.2.2) lib/sass/plugin/rails.rb:19:in
>> > > `process_without_compass'
>> > > /Library/Ruby/Gems/1.8/gems/chriseppstein-compass-0.8.10/lib/compass/
>> > > app_integration/rails/action_controller.rb:7:in `process'

If you open up a ./script/console prompt and type:
> Twitter::Client.new(:login => "somelogin", :password => "password")

Do you get the same ArgumentError?

If you open up a regular IRB without any Rails stuff loaded in what
happens when you run:
> require 'rubygems'
> require 'twitter4r'
> Twitter::Client.new(:login => "somelogin", :password => "password")

??

Thanks,

mtin79

unread,
Aug 24, 2009, 12:57:46 PM8/24/09
to twitter4r-users
oh dear,
after dissecting half of my ruby and rails application environment i
finally did a full text search for "twitter" through the application.
i found a Twitter Module in the lib directory which another co-worker
left there as a placeholder. this was the namespace collision.
sorry! it seemed to be much trickier as it was...

thanks very much for your support!

Susan Potter

unread,
Aug 24, 2009, 7:18:07 PM8/24/09
to twitter4r-users
No worries. I am glad it got sorted out AND there is a record of this
stack trace on the Google Group, which might help someone else next
time.

Thanks for posting!
Reply all
Reply to author
Forward
0 new messages