I think you have looked at the tutorial from Mr. Heinemeier Hansson at least once or twice and have a similar setup.
rails new kamal_pg --css tailwind --skip-test --database=postgresql
cd kamal_pg
# Basic key operators to query the JSON objects : | |
# #> : Get the JSON object at that path (if you need to do something fancy) | |
# -> : Get the JSON object at that path (if you don't) | |
# ->> : Get the JSON object at that path as text | |
# {obj, n} : Get the nth item in that object | |
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE | |
# Date | |
# date before today |
class UsersReflex < ApplicationReflex | |
def search(name) | |
users = User.where("name LIKE :prefix", prefix: "#{name}%") | |
result = users.map { |user| { text: user.name, value: user.id }} | |
cable_ready.dispatch_event(name: "data", detail: {options: result}).broadcast | |
morph :nothing | |
end | |
end |
class CustomersReflex < ApplicationReflex | |
def lookup(search) | |
# use search string to do some kind of DB lookup here | |
self.payload = {} # I have NO IDEA what tom-select expects! | |
morph :nothing | |
end | |
end |
import ApplicationController from '../application_controller' | |
import SlimSelect from 'slim-select' | |
export default class extends ApplicationController { | |
static values = { | |
limit: Number, | |
placeholder: String, | |
searchText: String, | |
searchingText: String, | |
reflex: String, |
$ bin/rails s
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
[WARNING] Could not load command "rails/commands/server/server_command". Error: Rails::Engine is abstract, you cannot instantiate it directly..
# "I'm losing my mind on concurrency" | |
# https://www.reddit.com/r/ruby/comments/lmg8xo/im_losing_my_mind_on_concurrency/ | |
require 'polyphony' | |
require 'httparty' | |
require 'json' | |
CHANNELS = ['list', 'of', 'channels'] | |
JOB_QUEUE = Queue.new | |
TIMEOUT = 60 # 60 second timeout |
This gist is an ES module which provides functions to import and export data from an IndexedDB database as JSON. It's based on Justin Emery's indexeddb-export-import
package, but applies some adjustments that reflect better on the current browser landscape (i.e. better developer ergonomics but no support for Internet Explorer).
For each of the provided functionalities, you need a connected IDBDatabase
instance.
import { idb } from 'some-database'
Feedback loop speed in one of the biggest contributing factors to overall development time. The faster you get results, the faster you can move on to other things. A fast enough test suite is therefore critical to teams' success, and is worth investing some time at the beginning to save in the long run.
Below is a list of techniques for speeding up a Rails test suite. It is not comprehensive, but should definitely provide some quick wins. This list of techniques assumes you're using minitest
, but most everything should translate over to rspec
by simply replacing test/test_helper.rb
with spec/spec_helper.rb
.
module Slug | |
def self.customize(field: :name) | |
Module.new do | |
define_method :to_param do | |
public_send(field).downcase.gsub /\W+/, '-' | |
end | |
end | |
end | |
end |