Rail support help

2 views
Skip to first unread message

GMelton

unread,
Jul 22, 2007, 1:55:39 PM7/22/07
to twitter4r-users
Susan,

I've been playing around with your api for the last couple of days and
I love it.

If you have a minute to respond I wanted to ask you about a problem
I'm having with hooking twitter4R into a rails controller.

I've created a wrapper class (twitter_proxy) around your API with
essentially one method with calls client.status(:post, msg).

At the top of my class I've included these three lines...

require 'rubygems'
gem 'twitter4r', '>=0.2.0'
require 'twitter'

When I run this class directly from command line => ruby
twitter_proxy.rb it works with no problems at all.

However, when I try and instantiate my wrapper class inside a rails
controller, I start noticing problems (see stack below). It's a
strange error. Working backwards, I commented anything which has to do
with twitter4R from my wrapper class and checked again and it works
fine -- even though I'm not calling any of the twitter4R api methods
at this point. It's starts to break the minute I add the require
'twitter' line back.

I'm not sure what do here. I read the other post about accessing the
api through rails and I didn't see anything relevant to this. After
looking through the gem I noticed the main twitter.rb file loads a few
other files. Is there a possibility rails doesn't have access to one
of the other required files, like, jcode? I installed the prereq JSON
gem at the same time I installed twitter4R so I'm not sure what else
it could be.

On a side note: while accessing other gems, like Hpricot, I've noticed
I don't have to always have to include the require 'hpricot' from my
controllers. I tried that too and no luck with twitter4R.

Please let me know if you need to see any my source code and I'll post
again.

Thanks for any help you have to offer,
Greg

-------------------------------------------

CommentsController: missing default helper path comments_helper
wrong number of arguments (1 for 0)

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
base.rb:1176:in `to_s'

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
base.rb:1176:in `request_origin'

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
base.rb:1087:in `log_processing'

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
base.rb:429:in `process_without_filters'

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
filters.rb:624:in `process_without_session_management_support'

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
session_management.rb:114:in `process'

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/
base.rb:330:in `process'

c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in
`dispatch'

c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:
113:in `handle_dispatch'

c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in
`service'

c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'

c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'

c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'

c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'

c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'

c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'

c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'

c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'

c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'

c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:63:in
`dispatch'

c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/
webrick.rb:59

c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'

c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'

c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:495:in `require'

c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:342:in `new_constants_in'

c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:495:in `require'

c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39

c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'

c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'

script/server:3

SP

unread,
Jul 22, 2007, 2:38:50 PM7/22/07
to twitter4r-users
Greg,

Thanks for the information. I have a few things to do this afternoon,
but I will check this situation out later this evening and hopefully
get back to you by tomorrow (US time).

Without knowing anything about this issue yet, if you can, please send
along any (if applicable) code in your CommentsHelper that references
either your TwitterProxy or any Twitter4R APIs directly in the
meantime.

Thanks,
Susan

GMelton

unread,
Jul 22, 2007, 4:46:49 PM7/22/07
to twitter4r-users

Susan, I uploaded a brand new rails app to the group in the test.zip
file with one controller, matching view, and helper file for
simplicity. I still have the same problem as before. You can see the
code in /app/controllers/comments_controller.rb file. Simply adding
require 'twitter' causes this unknown error. (BTW: my original project
was missing the comments_helper file -- this test project has it,
though). Again, thank you in advance for any help on this!

- Greg

----------------------------
test project stack for this error...

SP

unread,
Jul 23, 2007, 3:29:30 PM7/23/07
to twitter4r-users
Greg,

Sorry for the delay and thanks for the additional information and
zip. My laptop died last night and the only serious computer I have
all configured for Ruby/Rails work is at work now. I fiddled with
this over lunch time and ordered in.

Here is the nuts of it: Twitter4R currently extends the Ruby standard
library in a way that seems to conflict with a Rails Gem (most likely
ActiveSupport).

However, I found a workaround (I think). I will be uploading a
working Rails app zip file to the Group before I leave work tonight.

To track the full diagnosis of this problem (like which ActiveSupport
extension does Twitter4R conflict with, etc.) I have created a
Retrospectiva ticket (#34):
http://retro.tautology.net/projects/twitter4r/ticket/34

Twitter4R status: due to my laptop dying and having to wait 2 weeks to
get it repaired by Sony, I suspect the Twitter4R v0.3.0 release will
be delayed. Currently I had that scheduled for mid August.

I'll email a short reply when I have uploaded the zip file tonight (my
end of work day varies from 6pm to 9pm US Central time currently).

Thanks,
Susan
-
www:http://susanpotter.net
blog:http://snakesgemscoffee.susanpotter.net
linkedin:http://linkedin.com/in/susanpotter

GMelton

unread,
Jul 23, 2007, 10:36:49 PM7/23/07
to twitter4r-users
Susan,

Thanks for looking into this and I'm sorry to hear about your laptop.

I'd love to take a look at the workaround but there's no rush on my
end.

Thanks,
Greg

SP

unread,
Jul 24, 2007, 10:37:41 AM7/24/07
to twitter4r-users
Greg (and any other Rails developers),

I uploaded a sample Rails application that should work using Twitter4R
v0.2.x (where x <= 3) to the Google Group (it is called
twitter4rails.sample.zip). I also renamed the file you uploaded from
test.zip to railsapp.errors.zip.

Don't worry about rushing me. I realize many people will want to use
Twitter4R in their Rails projects, so I will start working on a Rails
plugin for Twitter4r that will remove the headache of this workaround
(or at a minimum a Rails generator in the form of a Plugin).

The files to look at in this sample Rails application are:
* config/environment.rb (near the bottom)
* config/twitter.yml
* config/twitter4r.rb
* app/controllers/tweets_controller.rb (for how I used Twitter4R
within a controller).

I will also commit this to Rubyforge and create a file download in the
twitter4r project.

I will also be correcting the one line (it was the fact that when I
overrode Time#to_s I didn't provide an optional parameter) in
Twitter4R and hopefully this evening and releasing the 0.2.4 EBF!:)
In my defense I was trying not to introduce any more Ruby Gem
dependencies than absolutely necessary, thus why I tried to steer
clear of using ActiveSupport in Twitter4R.

Reply all
Reply to author
Forward
0 new messages