mbleigh / twitter-auth

Standard authentication stack for Rails using Twitter to log in.
355 stars 48 forks source link

Can't call User#twitter from User class #23

Open marnen opened 14 years ago

marnen commented 14 years ago

I'm having a strange problem. If I call current_user.twitter.get('statuses/friends_timeline') from a controller, it works as expected. However, if I do this:

controller

current_user.timeline

User

def timeline
  twitter.get('statuses/friends_timeline')
end

...I get a NoMethodError: can't call downcase on NilClass. After a bit of debugging, it seems that when the OAuth module generates a signature, for some reason, it's not setting the hostname properly (so it's still nil, so it doesn't respond to downcase), with the result that request-uri is something like http::80/statuses/friends_timeline.

But it's baffling to me that it works in one case and not in the other, because I don't see any functional difference in how the methods are being called in the two cases. This is particularly frustrating since I'm trying to put logic in the model, not the controller, and TwitterAuth is preventing me from doing so.

Please help.

marnen commented 14 years ago

BTW, post is no problem when called from User. Go figure.

marnen commented 14 years ago

No, I spoke too soon. Post has the same problem.

marnen commented 14 years ago

This is apparently not a TwitterAuth issue. I'll be darned if I can figure out what's causing it, because I have two apparently identical commits, of which one always causes the error and the other never does, but TwitterAuth is off the hook.

marnen commented 14 years ago

Trying to close issue.

marnen commented 14 years ago

Grrr. Comment and Close is not working. Would someone put this ticket out of its misery? :)