Implementing a Custom Payment Gateway in Rails for Subscriptions...
app/models/comment.rb class Comment < ApplicationRecord after_create_commit { broadcast_append_to "comments" } end erbCopy code<!-- app/views/comments/index.html.erb --> <%= turbo_stream_from "comments" %> <div id="comments"> <%= render @comments %> </div>
javascriptCopy code// app/javascript/controllers/form_controller.js import { Controller } from "stimulus" export default class extends Controller { static targets = ["name"] validate() { if (this.nameTarget.value === "") { this.nameTarget.classList.add("error") } else { this.nameTarget.classList.remove("error") } } } erbCopy code<!-- app/views/users/_form.html.erb --> <div data-controller="form"> <input type="text" data-form-target="name" onkeyup="this.validate()"> </div>
Sign up for free and be the first to get notified about new posts.
No comment