-
Робите окрему папку (поки для простоти так, потім коли розберетесь зрозумієте що можна по-іншому)
-
Створюєте Dockerfile в тій папці
-
В Dockerfile пишете щось виду
FROM ubuntu:22.04
def display_name
Rails.cache.fetch("profile_#{id}_display_name", expires_in: 1.month) do
nickname_from_email
end
end
def masked_email
Rails.cache.fetch("profile_#{id}_masked_email", expires_in: 1.month) do
Since Rails 7 the turbo-rails library is included by default. Turbo Drive intercepts link clicks and form submits. It makes sure that only the <body>
part of the page is rerendered instead of the whole page.
This leads to TinyMCE not being properly detached and reattached when a Turbo Drive response is rendered. The textarea will appear without the TinyMCE editor. In this post we expand on the tinymce-rails
gem with a Stimulus controller to prevent this issue. The controller helps to reattach TinyMCE and respects the settings in config/tinymce.yml
.
If you want to follow along or check out the end result you can find an example respository here: https://github.com/david-uhlig/example-tinymce-rails7-turbo
# Pin npm packages by running ./bin/importmap
pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "https://ga.jspm.io/npm:@hotwired/stimulus@3.2.1/dist/stimulus.js"
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_all_from "app/javascript/controllers", under: "controllers"
pin "stimulus-use", to: "https://ga.jspm.io/npm:stimulus-use@0.52.0/dist/index.js"
gem 'rmagick'
and
bundle
Stimulus Controller (name: 'star-rating')
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static values = {
createInput: { type: Boolean, default: false },
inputName: { type: String, default: "rating" },
Model Comment
class Comment < ApplicationRecord
belongs_to :user
has_rich_text :content
after_create_commit do
broadcast_append_to :comments, target: "comments", partial: "comments/comment_for_stream", locals: { comment: self }
update_counter
end
app/views/layouts/application.html.erb
<body class="min-h-screen relative">
<%= render "layouts/flash" %>
</body>
app/views/layouts/_flash.html.erb
Stimulus controller (name: 'content-swipe-tab' )
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = ["tabs", 'tabsPane', "swipeArea"]
//[TODO] перенести у static values
static swipeThreshold = 100 // Пороговое значение для определения свайпа (чтобы мелкие движения не учитывались)
startX = null
startY = null
require "active_support/ordered_options"
require 'benchmark/ips'
require 'ostruct'
data = { x: 100, y: 200 }
PointStruct = Struct.new(:x, :y)
point_options = ActiveSupport::OrderedOptions.new