Category: Ruby on Rails
-
Deployment
So far, we have learned about various features of the Rails framework by building the applications on the locally running Puma server. In this chapter, we will learn how to deploy a Rails application on a publicly accessible server. Deploy with Rails Kamal Rails comes with a deployment tool called Kamal that we can use to deploy our application directly…
-
Error Handling
In Rails, error handling mainly works through a combination of Ruby exception handling (begin-rescue-end blocks) and Rails’ built-in mechanisms for managing errors in web requests, models, and controllers. Difference between Error and Exception In programming, you come across the terms exception and error, which have different meanings. An exception represents an error condition in a program. Exceptions…
-
Rack
Rack provides a minimal, modular, and adaptable interface for building web applications. It wraps HTTP requests and responses in the simplest way possible, and unifies and distills the API for web servers, web frameworks, and middleware into a single method call. The standardized Interface of Rack is common for all web applications and web servers. This interface expects…
-
Send Emails
Action Mailer is the Rails component that enables applications to send and receive emails. The other email related component in the Rails framework is Action Mailbox, which deals with receiving emails. Action Mailer Action Mailer uses mailers classes and views to create and configure the email to be sent. Mailer class inherits from ActionMailer::Base. It is similar to controller…
-
File Uploading
You may have a requirement in which you want your site visitors to upload a file on your server. Rails makes it very easy to handle this requirement. Now we will proceed with a simple and small Rails project. As usual, let’s start off with a new Rails application called FileUploadapp. Let’s create the basic structure…
-
Action Cable
Rails follows the MVC architecture and by default uses the HTTP protocol to handle the request-response cycle in a web application. However, since Rails version 5, the Action Cable feature was included to lend support for the new WebSocket protocol. Unlike the HTTP protocol, WebSocket is an asynchronous protocol, thus enabling real-time communication between the…
-
WebSockets
In this chapter, you will learn how to use the Action Cable feature in Rails to build a real-time chat application that employs the WebSocket protocol. What are WebSockets? The World Wide Web primarily works on the principle of REST, which encapsulates the HTTP protocol. However, one of its drawbacks is that it can be slower for…
-
AJAX
Ajax stands for Asynchronous JavaScript and XML. Ajax is not a single technology; it is a suite of several technologies. Ajax incorporates the following − Ajax enables you to retrieve data for a web page without having to refresh the contents of the entire page. In the basic web architecture, the user clicks a link or…
-
ImportMap
In Rails, the Asset Pipeline library is designed for organizing, caching, and serving static assets, such as JavaScript, CSS, and image files. In this chapter, you will learn about ImportMap that streamlines and optimizes the delivery of JavaScript to enhance the performance and maintainability of the application. From Version 7, Rails uses ImportMaps as default, enabling building…
-
Propshaft
Asset Pipeline in Rails is a framework that helps you manage and deliver static assets â like JavaScript, CSS, and image files â in an organized, efficient, and performant way. Earlier versions of Rails used a gem called Sprockets for the asset pipeline. However, there has been a lot of evolution of Asset Management Techniques within the last few years, leading to…