- Setup a new Rails app
- Initialize a local repository using git
- Create a new remote repository using GitHub
- Change README.rdoc
- Deploy to a cloud service - Heroku
- Ruby is installed (v 1.9.3)
- Rails is installed (v 3.2.3)
| options = { :body => | |
| { :username => 'my', | |
| :password => 'password' | |
| } | |
| } | |
| results = HTTParty.post("http://api.topcoder.com/v2/auth", options) | |
| ## | |
| ## example for post with papertrail and basic auth | |
| ## |
| Afghanistan | |
| Albania | |
| Algeria | |
| Andorra | |
| Angola | |
| Antigua & Deps | |
| Argentina | |
| Armenia | |
| Australia | |
| Austria |
| { | |
| "countries": [ | |
| { | |
| "country": "Afghanistan", | |
| "states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"] | |
| }, | |
| { | |
| "country": "Albania", | |
| "states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"] | |
| }, |
In this episode we're going to be adding realtime notifications into your app using ActionCable. We've talked about notifications a few times in the past and we used AJAX polling for that. 95% of the time, polling is the solution that would be recommended for it.
But if you're looking for a good introduction into ActionCable then this is a decent one because we're only really using it for one way from the server side to the client side.
So to get started we're starting with an app that has Bootstrap installed and then we created a Main controller with an index view which is where we will list our Notifications as for this example.
Before we generate our channels let's install a few things
I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do| Format Meaning | |
| %a The abbreviated weekday name (“Sun’’) | |
| %A The full weekday name (“Sunday’’) | |
| %b The abbreviated month name (“Jan’’) | |
| %B The full month name (“January’’) | |
| %c The preferred local date and time representation | |
| %d Day of the month (01..31) | |
| %H Hour of the day, 24-hour clock (00..23) | |
| %I Hour of the day, 12-hour clock (01..12) | |
| %j Day of the year (001..366) |
| <div class="container"> | |
| <div class="row"> | |
| <div class="col-md-3"> | |
| <%= render 'sidebar' %> | |
| </div> | |
| <div class="col-md-9"> | |
| <table class="table table-bordered"> | |
| <thead> | |
| <tr> |
| /* Dropdown */ | |
| .dropdown ul.dropdown-menu { | |
| border-radius:4px; | |
| box-shadow:none; | |
| margin-top:20px; | |
| } | |
| .dropdown ul.dropdown-menu:before { | |
| content: ""; | |
| border-bottom: 10px solid #fff; | |
| border-right: 10px solid transparent; |