title: Ruby: Make a call from browser using Twilio
body: <p>I want to call from my browser to customer phone number using Twilio. I am using <a href="https://www.twilio.com/docs/quickstart/ruby/client/hangup" rel="nofollow">toturial</a> of Twilio. I have already an account that I am using for sending sms to my users. Now I want to make phone calls too. This is the code that I am using at my controller</p>
  
  <pre><code>account_sid = "My Twilio account SID"
  auth_token = "My Twilio auth"
  sender = "My Twilio from number"
  capability = Twilio::Util::Capability.new account_sid, auth_token
  capability.allow_client_outgoing "My Twilio Twiml app sid"
  #capability.allow_client_incoming "jenny"
  @token = capability.generate
  </code></pre>
  
  <p>And this is the javascript code </p>
  
  <p></p>
  
  <pre><code>  Twilio.Device.setup("&lt;%= @token %&gt;", {debug: true});
  
    Twilio.Device.ready(function (device) {
        $("#log").text("Ready");
    });
  
    Twilio.Device.error(function (error) {
        $("#log").text("Error: " + error.message);
    });
  
    Twilio.Device.connect(function (conn) {
        $("#log").text("Successfully established call");
    });
  
    Twilio.Device.disconnect(function (conn) {
        $("#log").text("Call ended");
    });
  
    Twilio.Device.incoming(function (conn) {
        $("#log").text("Incoming connection from " + conn.parameters.From);
        // accept the incoming connection and start two-way audio
        conn.accept();
    });
  
    function call() {
        // get the phone number to connect the call to
        params = {"PhoneNumber": $("#number").val()};
        Twilio.Device.connect(params);
    }
  
    function hangup() {
        Twilio.Device.disconnectAll();
    }
  </code></pre>
  
  <p></p>
  
  <p>But when I try to load my page, it gives me <code>Error: No valid account</code>. I have double checked my credentials and same credentials are successfully sending sms but here it is creating problem. Can any one guide me what Am I doing wrong?</p>
  
  <p>I am doing it on localhost</p>