Step by Step Guide to using Cursor AI to Add a Blog (with Markdown support) to a Ruby on Rails App

Step #1:  Project Overview

Expected Output: Text

This is just to give the LLM an overview of what we are trying to achieve.

Notes/Instructions

Step #2:  Generate the Post model via the Rails' CLI

Expected Output: Text

We are going to assume you already have a User model that you'd like to integrate with the Blog, so that Posts belong to users.

Notes/Instructions

Step #3:  Run the Migrations

Expected Output: Text

It is necessary to run the migrations after any schema change.

Notes/Instructions

Step #4:  Update Post model with Associations + Create a Posts Controller nested under a New Blog Module

Expected Output: Text


Step #5:  Require Authentication for the non-public Post Controller Actions

Expected Output: Text

After adding this, you may want to do a "bin/rails routes" just to see all the routes that have been created.

Notes/Instructions

Step #6:  Adding views for the Posts controller for the index, new, edit and show Actions

Expected Output: Multiple files

You'll want to modify the prompt to use the appropriate CSS framework if you are not using Tailwind, or none.

Notes/Instructions

Step #7:  Use a Single _form Partial for the New and Show Views

Expected Output: Multiple files

I had to tell Cursor to do this. I think it's a cleaner approach overall and cuts down on code updating to modify the form views, etc.

If you are using a dark theme, it may have generated labels & text that are hard to read. I had to give it this prompt to update the views to work better with my dark theme:

My theme is a dark mode theme. Please update the new blog posts controller views to work better with a dark mode theme. text colors and labels should be white, etc

Notes/Instructions

Step #8:  Make Sure the User has a Posts Association

Expected Output: Text

After this, try visiting "/blog/posts" as an admin and add several posts. You will still likely need to tweak the CSS of course to get it to look nice.

Notes/Instructions

Step #9:  Update the Posts Index View to be more Blog-like

Expected Output: Text


Step #10:  Ew, these Post URLs Suck! Let's Make em look nice!

Expected Output: Text

Cursor does not seem to play nice with rails migrations (generating them for us), so let's add one by hand using the CLI.

Notes/Instructions

Step #11:  Some Minor Code Updates to get Slugs Working

Expected Output: Text


Step #12:  Prepare for Enabling Markdown Support for Blog Post Bodies

Expected Output: Text


Step #13:  Enable Markdown Support for Rendering Post Content

Expected Output: Multiple files

This should generate the necessary code to complete the addition of Markdown formatting support for posts. I had to tweak the application.tailwind.css file it generated and include it in my main application.css file, and even then it did not look great. But it's a starting point.

This concludes my How to Add a Blog to a RoR App AI Prompt tutorial. There's plenty left to do from here, of course--such as adding categories or tags, etc. If you want to extend this AI Prompt project, sign up for an account on Prompt Maven and create a new AI Prompt Project to explain how you'd do so. Thanks!

Notes/Instructions



e

Maximize your AI productivity.
Start using Prompt Maven today. today.

Prompt Maven allows you to create, manage and share complex, multi-stage AI prompts with your teams and the world.