by p4xio
In this multi-step AI prompt project, I will go over how to add a Blog (with Markdown formatting support) to your existing Ruby on Rails webapp. It 's not the most complex process, but there may be some gotchas that come up when adding this to an existing RoR app.
This will just be a basic Blog without categories, etc. Just the ability to create posts, etc.
For this workflow, I will be using Cursor AI, but the process should work similarly for other AI-powered code editors and tools.
Follow me on X for more AI prompt workflows:
Expected Output: Text
This is just to give the LLM an overview of what we are trying to achieve.
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.
Expected Output: Text
It is necessary to run the migrations after any schema change.
Expected Output: Text
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.
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.
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
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.
Expected Output: Text
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.
Expected Output: Text
Expected Output: Text
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!
Prompt Maven allows you to create, manage and share complex, multi-stage AI prompts with your teams and the world.
Copyright © Prompt Maven 2024. All rights reserved.