- Platform: YouTube
- Channel/Creator: Malachi Rails
- Duration: 01:02:04
- Release Date: Aug 8, 2025
- Video Link: https://www.youtube.com/watch?v=XNDOqznkZ4Y
Disclaimer: This is a personal summary and interpretation based on a YouTube video. It is not official material and not endorsed by the original creator. All rights remain with the respective creators.
This document summarizes the key takeaways from the video. I highly recommend watching the full video for visual context and coding demonstrations.
- I summarize key points to help you learn and review quickly.
- Simply click on
Ask AIlinks to dive into any topic you want.
Teach Me: 5 Years Old | Beginner | Intermediate | Advanced | (reset auto redirect)
Learn Differently: Analogy | Storytelling | Cheatsheet | Mindmap | Flashcards | Practical Projects | Code Examples | Common Mistakes
Check Understanding: Generate Quiz | Interview Me | Refactor Challenge | Assessment Rubric | Next Steps
- Summary: The course recreates a real website like malle.com, featuring Stripe payments, OmniAuth login, pro-only posts, search, filters, and categories. Start by installing Rails 8, then run
rails new malaki_rails_clone --database=postgresql --css=tailwindto set up the app with PostgreSQL and Tailwind CSS. Userails g scaffold post title:string description:text thumbnail_url:string video_url:string pro:booleanto generate the Post model, then migrate withrails db:migrateand start the server withrails s. - Key Takeaway/Example: Rails scaffolds provide instant CRUD functionality out of the box, making it quick to build and test models like posts.
- Link for More Details: Ask AI: Rails Project Setup
- Summary: To improve privacy and SEO, add the
friendly_idgem to your Gemfile, runbundle install, then generate migrations likerails g migration add_slug_to_posts slug:uniqandrails g friendly_id. Update the Post model withextend FriendlyIdandfriendly_id :title, use: :slugged, and modify the controller'sset_postto usefriendly_find. This replaces numeric IDs in URLs with slugs based on the post title. - Key Takeaway/Example: After setup, new posts use titles in URLs, like
/second-postinstead of/posts/2. - Link for More Details: Ask AI: Friendly ID in Rails
- Summary: Generate a Pages controller with
rails g controller pages home pricing privacy. Render a partial for post lists in the home view, adding Tailwind classes for grid layout. Create a helper method inposts_helper.rbto extract YouTube thumbnails from video URLs using regex. Include the Tailwind CDN inapplication.html.erbfor development styling. - Key Takeaway/Example: The thumbnail helper parses YouTube IDs:
def youtube_thumbnail(post) id = post.video_url.match(/embed\/([\w-]+)/)[1] "https://img.youtube.com/vi/#{id}/hqdefault.jpg" end
- Link for More Details: Ask AI: Styling and YouTube Embeds in Rails
- Summary: Create partials for
_navbar.html.erband_footer.html.erb, rendering them in the application layout. Add a search form in the navbar using Turbo and Stimulus for real-time filtering. Inposts_controller.rb, filter posts withPost.where("title ILIKE ? OR description ILIKE ?", "%#{query}%", "%#{query}%")if a query param is present, and respond with Turbo Stream. - Key Takeaway/Example: The Stimulus controller submits the form on input:
import { Controller } from "@hotwired/stimulus" export default class extends Controller { submit() { this.element.requestSubmit() } }
- Link for More Details: Ask AI: Navbar and Real-time Search in Rails
- Summary: Add
devisegem, install withrails generate devise:install, and generate User model with additional columns like provider, uid, avatar_url. Seed an admin user indb/seeds.rbusing Rails credentials for secure email/password storage. Use before_actions in controllers to authenticate and ensure admin access for post edits. - Key Takeaway/Example: Admin check in controller:
def ensure_admin_user unless current_user.email == Rails.application.credentials.dig(:admin, :email) redirect_to root_path, alert: "You must be an admin to perform this action." end end
- Link for More Details: Ask AI: Devise Authentication in Rails
- Summary: Add OmniAuth gems for Google and GitHub, configure in
devise.rbwith credentials. Set up routes and callbacks controller to handle auth. Update User model withdevise :omniauthableand afrom_omniauthmethod to create or find users based on provider data. - Key Takeaway/Example: Callback handling creates users with auth info like name and avatar.
- Link for More Details: Ask AI: OmniAuth in Rails
- Summary: Generate Category and Categorization models for many-to-many association. Add
has_many :categories, through: :categorizationsto Post. In forms, use checkboxes for categories; permit in params. Filter in index with joins if category_id param is present. - Key Takeaway/Example: Filter query:
Post.joins(:categories).where(categories: { id: params[:category_id] }).distinct. - Link for More Details: Ask AI: Categories and Filtering in Rails
- Summary: Run
rails action_text:install, addhas_rich_text :descriptionto Post model, and change form fields tof.rich_text_area :description. This enables formatting like bold, italics, and images in post descriptions. - Key Takeaway/Example: Rich text preserves formatting in views automatically.
- Link for More Details: Ask AI: Action Text in Rails
- Summary: Add scopes to Post like
scope :pro, -> { where(pro: true) }. In show views, check if post is pro and user is subscribed; otherwise, show a subscribe message. Style with Tailwind for better layout. - Key Takeaway/Example: Conditional rendering: If pro and not subscribed, hide content and prompt to subscribe.
- Link for More Details: Ask AI: Pro Content Restriction in Rails
- Summary: Add
stripegem, configure API key in initializer. Create pricing page with plans, routes for checkout sessions. In controller, create Stripe sessions based on plan (monthly/yearly) using price IDs from credentials. On success, update user subscribed status. - Key Takeaway/Example: Checkout session:
Stripe::Checkout::Session.create({ customer_email: current_user.email, ... }). - Link for More Details: Ask AI: Stripe Payments in Rails
- Summary: Push code to GitHub, create Render web service with Ruby, add build script for bundle and migrations. Configure production settings like cache store, add master key and database URL. Troubleshoot errors like PG connections or table duplicates by adjusting configs and redeploying.
- Key Takeaway/Example: Build script:
#!/usr/bin/env bash; bundle install; rails assets:precompile; rails assets:clean. - Link for More Details: Ask AI: Deploying Rails to Render
About the summarizer
I'm Ali Sol, a Backend Developer. Learn more:
- Website: alisol.ir
- LinkedIn: linkedin.com/in/alisolphp