Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Rails 3.1 TemplateHandler compatibility. #12

Merged
merged 2 commits into from Jan 2, 2012

Conversation

jtrupiano
Copy link
Contributor

* Swiped from https://github.com/asanghi/excel_rails/commit/8a32d8573fbfa39d83a7e234c65adf6bcbcea86e

I thought I was going to have to fork the code for rails 3.0.x vs. 3.1.0 (as HAML does here: https://github.com/nex3/haml/issues/303 ) but the test suite passes without that ugly if statement even when I drop the activesupport dependency. You may want to test this with a rails 3.0.x app just to make sure-- if it fails you can just do the same thing that the haml patch does.

@qrush
Copy link

qrush commented Oct 23, 2011

👍, this is getting obnoxious

@stevegraham
Copy link
Owner

does this break 3.0.x?

@cj
Copy link

cj commented Dec 20, 2011

Does this fix uninitialized constant Mime::VOICE in rails 3.1.3 ?

@stevegraham
Copy link
Owner

@cj what version of twilio-rb are you using?

@cj
Copy link

cj commented Dec 20, 2011

The master git://github.com/stevegraham/twilio-rb.git

@cj
Copy link

cj commented Dec 20, 2011

@stevegraham so I no longer get that message but doing the example with res.say 'Damn this library is so ill dude!' in index.voice and respond_to :voice just shows a blank page....

@cj
Copy link

cj commented Dec 20, 2011

Started GET "/calls.voice" for 127.0.0.1 at 2011-12-20 11:31:03 -0600
  Processing by TwilioVbx::CallsController#index as VOICE
Completed 403 Forbidden in 0ms

Is what I'm getting. Looking at https://github.com/stevegraham/twilio-rb/blob/master/lib/railtie.rb I can't see why

@cj
Copy link

cj commented Dec 20, 2011

wow so something very strange is going on.... if I goto /calls.xml it works fine and pulls the data from index.voice (even going to /calls.json pulls the data from index.voice)

@stevegraham
Copy link
Owner

this is expected behaviour. using the voice mime type triggers request validation. twilio adds a request signature to the request headers. twilio-rb performs the same steps as twilio to create the signature using a shared secret, your auth token. if the results do not match, 403 forbidden is returned.

code: https://github.com/stevegraham/twilio-rb/blob/master/lib/twilio/request_filter.rb

explanation: http://www.twilio.com/docs/security#validating-requests

@cj
Copy link

cj commented Dec 20, 2011

When the request comes from twilio it gets the same 403 though......

@cj
Copy link

cj commented Dec 20, 2011

returned the HTTP status code 403. Please check the URL and try again. Is what I get from twilio's debugger

@cj
Copy link

cj commented Dec 20, 2011

also what's the point of validating .voice when .xml will return the content of index.voice without even validating... ?

@stevegraham
Copy link
Owner

weird, i have this code running on several apps in production without a problem. please check that the auth token in your application code matches the auth token for the account owning the number being called.

also the request filter changed recently, so bundle update twilio-rb too.

@cj
Copy link

cj commented Dec 20, 2011

I've done a bundle update and the auth_token is the correct one... still no luck :/ are your production apps rails 3.1.3 ones? Also is there a reason .xml and .json now use .voice files with no validation?

@cj
Copy link

cj commented Dec 20, 2011

I also get these in the logs:

DEPRECATION WARNING: Inheriting from ActionView::Template::Handler is deprecated. Since Rails 3, all the API your template handler needs to implement is to respond to #call. (called from <module:Handlers> at /Users/cj/.rvm/gems/ruby-1.9.3-p0@global/bundler/gems/twilio-rb-aed350e80278/lib/railtie.rb:7)
DEPRECATION WARNING: Including Compilable in your template handler is deprecated. Since Rails 3, all the API your template handler needs to implement is to respond to #call. (called from include at /Users/cj/.rvm/gems/ruby-1.9.3-p0@global/bundler/gems/twilio-rb-aed350e80278/lib/railtie.rb:9)

@stevegraham
Copy link
Owner

i've just updated an old app to use 3.1.3, redeployed, and tested with GET and POST requests from twilio-proxy. they both work for me, so this does not look like an issue with twilio-rb to me.

you can stop your application responding to arbitrary mime types by whitelisting the ones you want to allow using respond_to.

the deprecation warnings are valid and what this pull request will fix once merged. your issue is unrelated to this pull request.

@cj
Copy link

cj commented Dec 20, 2011

Strange, thank you for looking in to it this far. I forked the lib and disabled the twilio auth check for now just so I can develop my plugin, I'll create a new issue once it's done and maybe you can check it out to see why it isn't working with it. Many thanks.

@stevegraham
Copy link
Owner

no problem, if you get stuck or want to talk about your specific case in private feel free to email me at stevie AT twilio DOT com

stevegraham added a commit that referenced this pull request Jan 2, 2012
Rails 3.1 TemplateHandler compatibility.
@stevegraham stevegraham merged commit ac58b86 into stevegraham:master Jan 2, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants