Important
Only for Tailwind 3 and DaisyUI 4.
This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. All code included below!
Want more content like this, for free? Check out my free book, RailsAI!
def search_result
categories.each_with_object([]) do |category, keywords|
keywords << category.keywords.split(', ').select{ |c| c.include?(query) } unless category.keywords.blank?
end.flatten.tally.first(3).map(&:first)
end[1, 2, 2, 3].tally| # set ruby/rails version | |
| export DOCKER_RAILS_VERSION="7.0.1" | |
| export DOCKER_RUBY_VERSION="3.1.0" | |
| export RAILS_PROJECT_NAME="rails7" | |
| # create folder for the project and add Gemfile with necessary rails version | |
| mkdir "$RAILS_PROJECT_NAME" | |
| cd "$RAILS_PROJECT_NAME" | |
| echo "ruby '$DOCKER_RUBY_VERSION' | |
| source 'https://rubygems.org' | |
| gem 'rails', '$DOCKER_RAILS_VERSION'" > Gemfile |
Note: Before diving into this implementation, consider that there are more popular and potentially easier-to-use solutions for implementing Sign in with Apple in Ruby on Rails, such as Omniauth. If you prefer a more out-of-the-box approach, explore those alternatives.
This implementation of the Sign in with Apple service in Ruby on Rails is suitable for APIs, eliminating the need for views.
| (from : https://simplifiedthinking.co.uk/2015/10/03/install-mqtt-server/ ) | |
| Installing Brew | |
| The Mosquitto MQTT Server can be easily installed using Homebrew. If it’s not installed on your system already, then a quick visit to the homepage will give you all you need to get going. Homebrew is an OS X Package Manager for installing and updating non-Mac OS X utilities that are more commonly found in other variants of Linux. To install the basic package manager run the following command. | |
| ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
| Installing Mosquitto MQTT |
| require 'benchmark' | |
| require 'ostruct' | |
| REP = 1000000 | |
| User = Struct.new(:name, :age) | |
| USER = "User".freeze | |
| AGE = 21 | |
| HASH = {:name => USER, :age => AGE}.freeze |
| module ActiveAdmin::ViewHelpers | |
| include ApplicationHelper | |
| def show_image(p) | |
| p.object.image.nil? ? p.template.content_tag(:span, "No Upload Image Yet") : p.template.image_tag(p.object.image.url(:small)) | |
| end | |
| end | |
| module ActiveAdmin | |
| module Views | |
| class Footer < Component |
| # include from an initializer | |
| module HstoreAccessor | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| end | |
| module ClassMethods | |
| def hstore_accessor(hstore_attribute, *keys) | |
| Array(keys).flatten.each do |key| |