- Add tom-select to Rails app
yarn add tom-select- Add to 'app/javascript/stylesheets/application.scss'
@import "tom-select/dist/css/tom-select.bootstrap5";| <div class="form-group"> | |
| <%= form.label :type, "Type", class: "font-weight-bold" %> | |
| <%= form.select :type, ['TextQuestion', 'UrlQuestion'], { include_blank: true }, { class: "form-control", data: { action: "input->toggle#changed", target: "toggle.select" } } %> | |
| </div> | |
| <div class="form-group"> | |
| <%= form.label :name, "Name", class: "font-weight-bold" %> | |
| <%= form.text_field :name, class: "form-control" %> | |
| </div> | |
| <div class="form-group" data-target="toggle.element" data-values="UrlQuestion"> | |
| <%= form.label :url, "URL", class: "font-weight-bold" %> |
| // DISCLAIMER : You can now probably use `data-turbo-action="advance"` on your frame to perform what this controller is aiming to do | |
| // https://turbo.hotwired.dev/handbook/frames#promoting-a-frame-navigation-to-a-page-visit | |
| // Note that you probably want to disable turbo cache as well for those page to make popstate work properly | |
| import { navigator } from '@hotwired/turbo' | |
| import { Controller } from '@hotwired/stimulus' | |
| import { useMutation } from 'stimulus-use' | |
| export default class extends Controller { | |
| connect (): void { |
| --------- model Recipe ------------- | |
| 1) Controllers: Recipes | |
| ======================= | |
| class RecipesController < ApplicationController | |
| after_action :register_visit, only: :show | |
| attr_accessor :recipe | |
| helper_method :recently_recipes |
| -------------------- model Recipe + Favorites ----------------------- | |
| 1. Add pagination: | |
| =============== | |
| Gemfile | |
| ------- | |
| gem 'pagy' | |
| $bundle |
yarn add tom-select@import "tom-select/dist/css/tom-select.bootstrap5";| <style> | |
| .git-graph { | |
| text-align: left; | |
| line-height: 1; | |
| } | |
| .git-graph-row { | |
| clear: both; | |
| text-align: left; | |
| } | |
| .git-graph-cell { |
Для интеграции ChatGPT в приложение Rails вам потребуются следующие шаги:
Получите API-ключ GPT, откройте сайт https://openai.com/ и зарегистрируйте аккаунт, елкгда будут инструкции по получению ключа.
Добавьте библиотеку 'httparty' в файл Gemfile вашего приложения и запустите
bundle install| class AttachedValidator < ActiveModel::EachValidator | |
| # Active Storage validator to ensure that an attachment is attached. | |
| # | |
| # usage: | |
| # validates :upload, attached: true | |
| # | |
| def validate_each(record, attribute, _value) | |
| return if record.send(attribute).attached? | |
| errors_options = {} |
| format.pdf do | |
| html = ApplicationController.new.render_to_string( | |
| template: 'pdfs/test', | |
| formats: [:pdf], | |
| layout: 'layouts/pdf', | |
| assigns: { user: @user }, | |
| encoding: 'UTF-8' | |
| ) | |
| Ferrum::Browser.new(timeout: 7).tap do |browser| | |
| browser.content = html |