Lightning Talk: Should you create a new Rails app as API-only?

Summarized using AI

Lightning Talk: Should you create a new Rails app as API-only?

Stefanni Brasil • April 12, 2021 • online • Lightning Talk

In this Lightning Talk at RailsConf 2021, Steffani Brasil shares insights on building Rails APIs, highlighting her experiences and addressing common concerns faced by developers. The talk centers around a conversational narrative with her friend Chidi, a fictional character from the show 'The Good Place,' who struggles with decision-making regarding whether to use the Rails API only mode for his project.

Key Points Discussed:

  • Introduction to Rails API Only Mode:

    Steffani explains the Rails API only mode, designed for applications that require a backend serving JSON responses without the overhead of views and assets. She emphasizes that this mode is suitable for applications that interact with single-page applications (SPAs) or mobile native apps.

  • Client Considerations:

    The discussion posits essential questions for developers to consider:

    • Will the client be a SPA, mobile app, or another Rails application?
    • Will the client handle the user interface while the Rails API merely serves JSON? If the answer is yes to any of these questions, choosing the API only mode might be beneficial.
  • Structure of Rails API:

    Steffani describes the structure of a Rails API, pointing out that it is a lighter version of a standard Rails application.

    • It lacks views and helpers aside from mailer templates.
    • Controllers are simplified to only render JSON responses.
  • Addressing Decision Paralysis:

    Chidi's indecisiveness leads to a common concern: what if one realizes mid-development that more features are needed than initially anticipated? Steffani reassures developers that Rails is customizable, allowing for adjustments even after initial decisions are made. She encourages learning from these experiences as valuable opportunities for growth.

  • Conclusion and Resources:

    Steffani concludes by encouraging those interested in building Rails APIs to consider the points discussed and avoid indecision like Chidi’s. To aid in this process, she has created a cheat sheet available at a specified URL, which compiles the basic considerations addressed during her talk.

Overall, this talk succinctly communicates the essence of building Rails APIs while addressing the common anxieties surrounding decision-making in software development. The emphasis on practical experience and customization possibilities enhances the confidence of developers contemplating similar projects.

Lightning Talk: Should you create a new Rails app as API-only?
Stefanni Brasil • April 12, 2021 • online • Lightning Talk

RailsConf 2021

00:00:05.060 Okay, so hi everyone, I'm Steffani. I'm super happy to be here and I've been working with Rails for the past four years. Recently, I have been working with Rails APIs and I want to tell you a story.
00:00:15.780 I have a friend named Chidi Anagonye, and he's an IT and philosophy professor. He has trouble making decisions about anything. One day, he came to me and said, 'Hey Steffani, I'm thinking of building an API. Do you think I should go with the Rails API only mode?'
00:00:30.900 I responded, 'Actually...' but he continued, 'If I just look for authentication, I find a bunch of different recommendations, and it's really confusing.' I said, 'Wow, Chidi, I also feel that frustration. Let me see if I can help you.' It will depend: do you know if your client could be a single-page application, a mobile native app, or even another Rails application that renders all the HTML pages? Do you know if your client will create all the interfaces that your end users will see?
00:00:54.719 Then I asked if your Rails API would only be responsible for serving the JSON resources so that the client can display it to the user. If you answered 'yes' to any of those questions, then yes, it might be a good choice for you because that's actually why the Rails API was built. Chidi asked me, 'Okay, so how does that look?' I explained that with a Rails API-only application, you get no views, no helpers, no assets, and no custom actions on your controllers, since those are usually where the user inputs data. Moreover, since Rails APIs are stateless, you won't have the management of the browser's user sessions.
00:01:44.820 Chidi wanted to see the structure of the application, so I told him that it's a lighter version of a regular full-stack Rails app. For example, you don't get the assets, you don't get the helpers, but you do get the views, though only for the mailer templates. It's also important to note that the controllers will only render JSON.
00:02:21.660 Chidi, of course, couldn't make a decision. He asked, 'What if I decide to use the Rails API-only mode and find out later that I actually need more features?' I reassured him, 'Don't worry about it because Rails is really customizable. You can add all the features back, and the most important part is that you can learn from this experience. You'll learn a lot about Rails configurations.'
00:03:11.220 Of course, Chidi can't decide, but if you, my friend, are considering building a Rails API and you don't know if you should go with the Rails API-only mode, I hope you got some ideas on what to consider. That way, you won't have to be like Chidi. By the way, all the characters in this story are from 'The Good Place.'
00:03:34.620 I also share Chidi's frustration, and because of that, I decided to compile all of these basic things into a cheat sheet. You can find that at this URL along with these slides. That's it! Thank you, everyone, for the opportunity, and that’s me.
Explore all talks recorded at RailsConf 2021
+65