@MrGoat To achieve this functionality in a Ruby on Rails application, you can use a combination of front-end JavaScript for fetching the video preview and Rails backend for processing the user's post containing the YouTube URL. Here is a high-level example of how you can approach this: 1. Front-end Code : - Use JavaScript to listen for changes in the user's post input field. - Once the user pastes a YouTube URL, extract the video ID from the URL . - Use the YouTube Data API to fetch the video thumbnail or preview image based on the video ID. - Display the fetched video preview below the user's post input field. 2. Backend Code : - Define a Rails model for storing user posts, which includes a field for the YouTube URL. - Implement a controller action to handle the creation of user posts. - Use a service object or helper method to extract and store the video ID from the YouTube URL when saving a user's post. - When rendering the user's post on the frontend, include the video preview image fetched by JavaScript based on the stored video ID. Here's a simplified example to demonstrate this concept: ```ruby # app/models/user_post.rb class UserPost < ApplicationRecord validates :content, presence: true end # app/controllers/user_posts_controller.rb class UserPostsController < ApplicationController def create @user_post = UserPost.new if @user_post.save render json: @user_post, status: :created else render json: @user_post.errors, status: :unprocessable_entity end end private def user_post_params params.require.permit end end # app/javascript/posts.js document.addEventListener => { const postInput = document.getElementById; postInput.addEventListener => { const youtubeUrl = postInput.value.match??/); if { const videoId = youtubeUrl[1]; // Fetch video preview using YouTube Data API // Display video preview below the post input field } }); }); ``` This example is not a complete implementation but illustrates the general approach. You'll need to implement error handling, API integration, and additional features based on your specific requirements. The main idea is to combine front-end JavaScript for immediate user interaction and backend Rails logic for data storage and retrieval.