Category: Ruby on Rails
-
JavaScript
In this chapter, you will learn how to integrate JavaScript functionality into your Rails application, and how you can use external JavaScript packages. This chapter also introduces Turbo which is used for creating fast, modern web applications without having to reach for a client-side JavaScript framework. In modern web development, we often break our JavaScript into many…
-
Action Text
In this chapter, you will learn how to handle rich text content in a Rails application with the help of Action Text component. We will cover the following topics in this chapter: What is Action Text? Installing Action Text enables you to display the rich text content – text that can including formatting features such…
-
Active Job
The Active Job framework in Rails is extremely helpful for declaring background jobs and executing them asynchronously. Applications that involve background tasks such as sending emails, pushing notifications, background processing of CSV files and backing up the databases, integration with external apps through APIs, handling file uploads, etc., can be scheduled with Active Job framework.…
-
Forms
The <form> . . </form> tag in HTML along with the form’s various input elements such text, radio, select, etc. help you to create HTML forms. For example, a basic form to accept user input for a new book record, written in plain HTML would be like this: <form action=”/books” method=”post”><label for=”title”>Title:</label><input type=”text” name=”title” id=”title”><label for=”author”>Author:</label><input type=”text” name=”author” id=”author”><label for=”price”>Price:</label><input…
-
Scaffolding
While you’re developing Rails applications, especially those which are mainly providing you with a simple interface to data in a database, it can often be useful to use the scaffold method. Scaffolding provides more than cheap demo thrills. Here are some benefits − To understand scaffolding, let’s start by creating a new Rails application named…
-
Layouts
When Rails renders a view as a response, it does so by combining the view with the current layout. A layout defines the surroundings of an HTML page. It’s the place to define a common look and feel of your final output. By default, Rails uses the app/views/layouts/application.html.erb file as the main layout. It is…
-
Rendering
In Rails, the controller is responsible for processing the incoming request and creating the response to be sent back to the client. The controller uses mainly the following three ways to create the response The render Method By default, controllers in Rails automatically render views with names that correspond to valid routes. The render method…
-
Views
A Rails View is an ERB program that shares data with controllers through mutually accessible variables. Rails uses ERB (Embedded Ruby) as its default template engine to interpret and process .html.erb files. If you look in the app/views directory of any Rails application, you will see one subdirectory for each of the controllers. Each of these subdirectories was created…
-
Routes
The routing module provides URL rewriting in native Ruby. It’s a way to redirect incoming requests to controllers and actions. It replaces the mod_rewrite rules. Best of all, Rails’ Routing works with any web server. Routes are defined in app/config/routes.rb. A route is the part of the URL that determines how an incoming HTTP request is directed…
-
Authentication
The library application used in this tutorial has the CRUD actions to add, edit, and delete book objects. However, these actions are accessible to anyone, which isn’t safe. Let us add a security layer to the application, so that only authenticated users get the access. Authentication Generator Starting with Rails version 8.0, a default authentication generator is included to streamline the…