class PostsController < ApplicationController
def index
@posts = Post.published
.order(created_at: :desc)
.page(params[:page])
.per(20)
module LayoutlessTurboFrame
extend ActiveSupport::Concern
included do
layout :layout_for_turbo
end
class TurboFailureApp < Devise::FailureApp
def respond
if turbo_request?
redirect_for_turbo
else
super
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["input", "results"]
static outlets = ["results-list"]
static values = {
class NotificationsController < ApplicationController
def mark_all_read
current_member.notifications.unread.update_all(read_at: Time.current)
streams = Turbo::Streams::TagBuilder.new(view_context)
<div id="save_state" class="text-xs text-gray-500">Not saved yet</div>
<div id="image_preview">
<%= render 'images/preview', record: @profile %>
</div>
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
<div class="posts-index">
<div class="sticky top-0 bg-white border-b" id="search-bar">
<%= form_with url: posts_path, method: :get, data: { turbo_frame: "_top", turbo_action: "morph" } do |f| %>
<%= f.search_field :q,
class PostsController < ApplicationController
def new
@post = Post.new
end
def create
<%= form_with url: autosave_draft_path,
method: :post,
local: false,
data: {
controller: "autosave",
autosave_target: "form",
class Recipe < ApplicationRecord
has_many :ingredients, inverse_of: :recipe, dependent: :destroy
accepts_nested_attributes_for :ingredients,
allow_destroy: true,
reject_if: :all_blank
<!DOCTYPE html>
<html>
<head>
<title>Contacts</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>