# In your Gemfile
gem "localhost"
# Then, depending on your desired server
gem "falcon"
gem "puma"| # All these requires are just for running via `irb`, if using `bin/rails console` you probably just need the method. | |
| require "active_support/all" # Got an inflector NoMethodError, so I'm just being lazy here. | |
| require "action_dispatch" | |
| require "action_dispatch/routing/route_set" | |
| require "action_dispatch/routing/inspector" | |
| require "action_controller" # For the ActionController::Parameters autoload, which any route helper uses. | |
| # Console helper play around with the routing DSL and tweak an individual route you're building. |
| Rails.application.configure do | |
| # Add Cloudflare's IPs to the trusted proxy list so they are ignored when | |
| # determining the true client IP. | |
| # | |
| # See https://www.cloudflare.com/ips-v4/ and https://www.cloudflare.com/ips-v6/ | |
| config.action_dispatch.trusted_proxies = ActionDispatch::RemoteIp::TRUSTED_PROXIES + %w[ | |
| 173.245.48.0/20 | |
| 103.21.244.0/22 | |
| 103.22.200.0/22 | |
| 103.31.4.0/22 |
| # Clone the repo | |
| git clone https://github.com/imartinez/privateGPT | |
| cd privateGPT | |
| # Install Python 3.11 | |
| pyenv install 3.11 | |
| pyenv local 3.11 | |
| # Install dependencies | |
| poetry install --with ui,local |
| # place this code in ~/.railsrc | |
| --css=tailwind | |
| --template=~/.rails/template.rb |
| class BaseClient | |
| class APINotFound < StandardError; end | |
| attr_reader :auth_strategy | |
| def initialize(auth_strategy: :headers, headers: {}) | |
| @auth_strategy = auth_strategy | |
| @headers = headers | |
| end |
Many times I want to always set the timestamps when a model is created. At times you will want to create a model in sql only for it to fail because you forgot to set the created_at and updated_at columns to some value. By setting a sane default you will avoid having to think about this in the future.
In your Rails application, copy the code below and paste it in the following file: lib/templates/active_record/migration/create_table_migration.rb.tt
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
def change
create_table :<%= table_name %><%= primary_key_type %> do |t|
<% attributes.each do |attribute| -%>
| class RoutingTest < ActionDispatch::IntegrationTest | |
| IGNORED_CONTROLLERS = Set[ | |
| "Rails::MailersController" | |
| ] | |
| test "no unrouted actions (public controller methods)" do | |
| actions_by_controller.each do |controller_path, actions| | |
| controller_name = "#{controller_path.camelize}Controller" | |
| next if IGNORED_CONTROLLERS.include?(controller_name) |
I am Cursor, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read ALL memory bank files at the start of EVERY task - this is not optional.
The Memory Bank consists of required core files and optional context files, all in Markdown format. Files build upon each other in a clear hierarchy:
flowchart TD| require "digest" | |
| require "rack" | |
| # This class encapsulates a unit of work done for a particular tenant, connected to that tenant's database. | |
| # ActiveRecord makes it _very_ hard to do in a simple manner and clever stuff is required, but it is knowable. | |
| # | |
| # What this class provides is a "misuse" of the database "roles" of ActiveRecord to have a role per tenant. | |
| # If all the tenants are predefined, it can be done roughly so: | |
| # | |
| # ActiveRecord::Base.legacy_connection_handling = false if ActiveRecord::Base.respond_to?(:legacy_connection_handling) |