class ProductsController < ApplicationController
PER_PAGE = 24
def index
@page = [params[:page].to_i, 1].max
@sort = %w[name price recent].include?(params[:sort]) ? params[:sort] : "recent"
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["source"]
async copy() {
import { StreamActions } from "@hotwired/turbo"
StreamActions.highlight = function () {
const className = this.getAttribute("data-highlight-class") || "flash-highlight"
const duration = parseInt(this.getAttribute("data-highlight-duration"), 10) || 1500
class Board < ApplicationRecord
has_many :cards, dependent: :destroy
belongs_to :owner, class_name: "User"
validates :name, presence: true
end
<%= turbo_frame_tag dom_id(contact) do %>
<tr class="contact-row">
<td><%= contact.name %></td>
<td><%= contact.email %></td>
<td><%= contact.role.titleize %></td>
<td class="actions">
class Import < ApplicationRecord
include ActionView::RecordIdentifier
enum status: { pending: 0, processing: 1, completed: 2, failed: 3 }
has_one_attached :file
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
class ActivityPanelController < ApplicationController
def show
@project = Project.find(params[:project_id])
@events = @project.events.order(created_at: :desc).limit(50)
latest = @events.maximum(:updated_at)
class Comment < ApplicationRecord
belongs_to :post
belongs_to :author, class_name: 'User'
# Automatically broadcast changes to all subscribers of this post
after_create_commit -> { broadcast_append_to post, target: "comments" }
class DashboardWidget < ApplicationRecord
broadcasts_refreshes
end
class CommentsController < ApplicationController
before_action :set_post
def create
@comment = @post.comments.build(comment_params)
Rails.application.routes.draw do
concern :tabs do
get :profile, on: :collection
get :billing, on: :collection
get :security, on: :collection
end