//= require_self
//= require_tree ./App

App = {};

App.setPath = function(path){
  history.pushState({}, document.title, path);
  $(window).trigger('pushstate');
};

App.router = function(path){

  if (path === '/') return <HomePage />
  if (path === '/tweet-box') return <TweetBox />
  return <div>Page Not Found</div>
}

$(function(){
  React.render(<MainComponent />, document.body);
});
//= require_self
//= require_tree ./App

App = {};

App.request = function(method, path, data){
  return new Promise(function(resolve, reject){
    var request = $.ajax({
      url:      path,
      method:   method,
      data:     data,
      dataType: "json"
    });

    request.done(function(serverData){
      resolve(serverData)
    });

    request.fail(function(serverData){
      reject(serverData)
    });
  });
};

App.goto = function(path){
  history.pushState({}, document.title, path);
  $(window).trigger('pushstate');
};

App.router = function(path){

  if (path === '/') return <HomePage />
  if (path === '/tweet-box') return <TweetBox />
  return <div>Page Not Found</div>
}

App.router = function(path){
  if (path === '/')                          return <HomePage />;
  if (path === '/tweet-box') return <TweetBox />;
if (path.match(/^\/questions\/(\d+)$/))        return <QuestionShowPage  question_id={RegExp.$1} />;
  return(
    <h1>Page Not Found</h1>
  )
};

$(function(){
  React.render(<MainComponent />, document.body);
});
Update router and ajax button for SPA
Update router and ajax button for SPA
