Josh Justice

Rails APIs (Part 4) - Custom Actions

Josh Justice | Sep 17, 2018

How can I create custom controller actions in Rails?

In past screencasts, we’ve set up a simple web service in Rails, deployed it to production, and added authentication. We let Rails generate the logic to perform create, read, update, and delete actions. That's worked well so far, but at some point we’re going to need to adjust or write our own controller code.

In this screencast, we’ll follow up on our previous videos in this series and show you how to rewrite custom controller actions in Rails.

After this screencast, you'll be able to…

- Understand how controllers generated by Rails scaffolding works
- Implement your own controller actions
- Access records in the database
- Specify what data and HTTP status to return
- Understand how Rails run model validations

Basic knowledge or experience building frontend applications is recommended.

For the More Curious...

Rails resourceful routing
Rails controller docs
CRUD with Rails models

Subscribers Only

Transcripts are for subscribers. Create an account today to access our collection of screencasts, skill packs, and more.

Subscribers Only

Project files are only available for subscribers. Create an account today to access our collection of screencasts, skill packs, and more.

Need Help?

If you get stuck, try starting a discussion with Big Nerd Ranch experts in the community tab.

Easy Backend APIs with Rails

This screencast is part of a skill pack called Easy Backend APIs with Rails.

Rails APIs (Part 1) - Getting Past the CRUD

8 minutes

In this screencast, we'll show you how to create a web service for tracking todos and we'll continue to build on this application throughout the rest of the series.

Rails APIs (Part 2) - Deploying

6 minutes

Whether you are building a prototype or a business critical product, Heroku makes it easy to deploy and scale web applications. If you’ve never run a production web application before this might sound intimidating, but don’t worry—we’re going to use Heroku, a platform that makes deploying apps incredibly easy. But first we have a little preparation to do.

Rails APIs (Part 3) - Authentication

7 minutes

In a previous screencast we set up a simple Rails web service for todos and deployed it to production. But right now there's no authorization on it, which means anyone can come along and modify our data. In this screencast, we’ll use the Doorkeeper gem makes it easy to add authentication to Rails APIs using the OAuth 2 standard.

Rails APIs (Part 4) - Custom Actions

9 minutes

In this screencast, we’ll follow up on our previous videos in this series and show you how to rewrite custom controller actions in Rails.

Rails APIs (Part 5) - Associations and Nested Routes

5 minutes

In this screencast, we’ll use the Doorkeeper gem makes it easy to add authentication to Rails APIs using the OAuth 2 standard.

Rails APIs (Part 6) - Authorization Rules

7 minutes

In a previous video we set up authentication for our Rails API, so that only logged in users can make changes. But sometimes more sophisticated rules are needed. In this screencast, we'll learn how to successfully add authorization to our API.

Rails APIs (Part 7) - Testing Web Services

8 minutes

In a previous screencasts, we built out a simple but full-featured web service. We have several tables of related data, validation, default values, and authorization. This is great, but it’s also starting to get complex enough that we might break something! Luckily, Rails’ testing support is second-to-none. In this screencast, we'll learn how to set up automated testing for our Rails web service.

Related Screencasts

Explore other screencasts related to this topic.

Extracting a React Component

8 minutes

Sometimes we don’t realize we should make a custom child component until it’s too late. In this screencast, we'll teach you how to extract a React component from an app.

Rails APIs (Part 1) - Getting Past the CRUD

8 minutes

In this screencast, we'll show you how to create a web service for tracking todos and we'll continue to build on this application throughout the rest of the series.

Rails APIs (Part 6) - Authorization Rules

7 minutes

In a previous video we set up authentication for our Rails API, so that only logged in users can make changes. But sometimes more sophisticated rules are needed. In this screencast, we'll learn how to successfully add authorization to our API.

Rails APIs (Part 5) - Associations and Nested Routes

5 minutes

In this screencast, we’ll use the Doorkeeper gem makes it easy to add authentication to Rails APIs using the OAuth 2 standard.

Rails APIs (Part 2) - Deploying

6 minutes

Whether you are building a prototype or a business critical product, Heroku makes it easy to deploy and scale web applications. If you’ve never run a production web application before this might sound intimidating, but don’t worry—we’re going to use Heroku, a platform that makes deploying apps incredibly easy. But first we have a little preparation to do.

Rails APIs (Part 7) - Testing Web Services

8 minutes

In a previous screencasts, we built out a simple but full-featured web service. We have several tables of related data, validation, default values, and authorization. This is great, but it’s also starting to get complex enough that we might break something! Luckily, Rails’ testing support is second-to-none. In this screencast, we'll learn how to set up automated testing for our Rails web service.