Learn Enough to Be Dangerous
You have to make a choice. Choose...wisely.

Get occasional notifications about things like product discounts, blog posts, and new or updated tutorials. Unsubscribe at any time.

Gift Delivery Options
Quick Checkout
or Pay by Credit Card
Error processing your payment
  • You didn't choose whether or not to be added to the mailing list
Confirm
$0.00

Payments and credit card details are securely managed and protected by Learn Enough's payment processor, Stripe. More information on their site:

CART
Total
$0.00

Your Cart is Empty

$30
$300
$300
$XY
$XY
1234
  • Action Cable

Learn Enough Society

Certificate of Course Completion

This page certifies that actionjdjackson has completed Learn Enough Action Cable to Be Dangerous! 🎉

About the tutorial
Learn Enough Action Cable to Be Dangerous is an introduction to Action Cable, a Ruby library that combines ultra-responsive real-time applications with the power and convenience of Rails. Learn to build and deploy a highly responsive chat app that takes advantage of Action Cable’s elegant interface to the WebSockets protocol. Read full post
14 Nov 13:16, 2020
3 Mar 16:02, 2023
Exercise Answers
Exercise Question:
  • Does the code in Listing 2.2 still work if you swap the order of the function call and its definition?
  • actionjdjackson's Answer:
    Exercise Question:
  • What happens if you replace 'hello, world!' in Listing 2.2 with '¡Hola, mundo!'?
  • actionjdjackson's Answer:
    Exercise Question:
  • Can you guess the jQuery syntax to select elements with a particular CSS class? Google it only if necessary.
  • actionjdjackson's Answer:
    Exercise Question:
  • What happens if you reverse the order of the appender and document on load in Listing 2.5?
  • actionjdjackson's Answer:
    Exercise Question:
  • What happens if you remove the parentheses in the call to message_appender in Listing 2.8?
  • actionjdjackson's Answer:
    Exercise Question:
  • Replace on data.content with data.username in Listing 3.5. Do you get the correct value?
  • actionjdjackson's Answer:
    Exercise Question:
  • Replace the alert in Listing 3.5 with a call to console.log. Use your browser’s web inspector to confirm that the correct value appears in the console (data.username if you completed the previous exercise, data.content otherwise). If you don’t have any experience with web inspectors or consoles, use your technical sophistication (Box 1.1) to figure it out.
  • actionjdjackson's Answer:
    Exercise Question:
  • Describe the steps taken when Alice sends a message to Bob.
  • actionjdjackson's Answer:
    Exercise Question:
  • What happens if you remove the preventDefault line in Listing 3.11?
  • actionjdjackson's Answer:
    Exercise Question:
  • Remove the call to f.submit in Listing 3.9 to see if $('input').click() still works.
  • actionjdjackson's Answer:
    Exercise Question:
  • Because of the authorization before filter in Listing 4.3, it’s a little tricky to test that the system is really rejecting unauthorized connections. One way is to comment out the logged-in user filter and then change logged_in? to false in Listing 4.1. This forces the system to execute the reject_unauthorized_connection branch of the if statement in find_verified_user. Can you tell by looking at the Rails server log if it worked?
  • actionjdjackson's Answer:
    Exercise Question:
  • Use console.log to determine the value of the scrollHeight in your current application. Hint: In most browsers, you can use console.log and jQuery directly in the web inspector console.
  • actionjdjackson's Answer:
    Exercise Question:
  • Make a gratuitous change to the message partial, such as adding a random word. Does the change appear for messages created using JavaScript?
  • actionjdjackson's Answer:
    Exercise Question:
  • Confirm that you can include links in your chat messages. How would you make the link Learn Enough to Be Dangerous (including italics), link to www.learnenough.com?
  • actionjdjackson's Answer:
    Exercise Question:
  • Using blockquote syntax for Markdown, enter a multi-line quote into the chat using Shift-Enter. Does the display look good? Improve the display by appending the Sass in Listing 5.6 to the end of main.sass.
  • actionjdjackson's Answer:
    Exercise Question:
  • Use the Markdown image syntax to include the image at https://cdn.learnenough.com/archer_ants.jpg. Are you able to get a result that looks something like Figure 5.5?
  • actionjdjackson's Answer:
    Exercise Question:
  • Write some Message model tests for the mentions method.
  • actionjdjackson's Answer:
    Exercise Question:
  • Include the SessionsHelper (as in Listing 4.1) and then try using current_user in Listing 5.7. What error do you get?
  • actionjdjackson's Answer:
    Exercise Question:
  • Extend the @mention functionality to include the mentioning user in the alert, as in “You have a new message from @bob”.
  • actionjdjackson's Answer:
    Exercise Question:
  • Why can’t you use the original unless from Listing 4.4 in Line 10 of Listing 5.10?
  • actionjdjackson's Answer:
    Exercise Question:
  • Confirm that your production app can replicate the behavior shown in Figure 5.7 and Figure 5.8.
  • actionjdjackson's Answer:
    Exercise Question:
  • Using the Heroku console, add a third sample user named “Charlie”, and confirm using a third web browser that all three users can chat simultaneously.
  • actionjdjackson's Answer:

    Join the Mailing List

    Get occasional notifications about things like product discounts, blog posts, and new or updated tutorials. Unsubscribe at any time.