Skip to content

Instantly share code, notes, and snippets.

@peterc
peterc / CONVENTIONS.md
Last active April 20, 2025 21:22
CONVENTIONS.md file for AI Rails 8 development
  • You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use rails new first to generate all of the boilerplate files necessary.
  • Create an app in the current directory with rails new .
  • Use Tailwind CSS for styling. Use --css tailwind as an option on the rails new call to do this automatically.
  • Use Ruby 3.2+ and Rails 8.0+ practices.
  • Use the default Minitest approach for testing, do not use RSpec.
  • Default to using SQLite in development. rails new will do this automatically but take care if you write any custom SQL that it is SQLite compatible.
  • An app can be built with a devcontainer such as rails new myapp --devcontainer but only do this if requested directly.
  • Rails apps have a lot of directories to consider, such as app, config, db, etc.
  • Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
  • Guard against incapable browsers accessing controllers with `allo
@fractaledmind
fractaledmind / router.rb
Created February 19, 2024 09:12
A singleton class for Rails apps to generate URLs easily from anywhere in their app.
# frozen_string_literal: true
module Router
class << self
include Rails.application.routes.url_helpers
def default_url_options
Rails.application.config.action_controller.default_url_options || {}
end
@davidteren
davidteren / active_support_tips_01.rb
Created June 7, 2022 18:19
A good way to validate whether an object is Truthy or Falsey in Ruby or Rails apps is to use the ActiveSupport present? & blank? methods.
# The Rails ActiveSupport core extensions provide additional
# functionality to any Rails or Ruby application.
require "active_support"
# ActiveSupport#blank?
nil.blank? # => true
false.blank? # => true
{}.blank? # => true
[].blank? # => true
"".blank? # => true
@GALTdea
GALTdea / index.html
Created July 4, 2021 00:12 — forked from labnol/index.html
A textbox that looks like a notepad! Forms are fun!
<div id="wrapper">
<form id="paper" method="get" action="">
<div id="margin">Title: <input id="title" type="text" name="title"></div>
<textarea placeholder="Enter something funny." id="text" name="text" rows="4" style="overflow: hidden; word-wrap: break-word; resize: none; height: 160px; "></textarea>
<br>
<input id="button" type="submit" value="Create">
</form>
</div>
@iscott
iscott / ds_and_algos.md
Last active October 30, 2023 12:41
Intro to Datastructures and Algorithms Cheat Sheet

The Minaswan::Interview

Session Format: Talk

Abstract

White-boarding is not nice. An unpaid take home project is not nice. We decided to apply the Ruby community motto "Matz is nice and so we are nice," to our enterprise technical interview process. Come learn what changes we made, how we enlisted support of other rubyists and non-rubyists alike, and how you can too.

Details

The current state of interviewing is not nice

@mrmartineau
mrmartineau / stimulus.md
Last active April 9, 2025 15:37
Stimulus cheatsheet
@ibraheem4
ibraheem4 / postgres-brew.md
Last active April 19, 2025 14:27 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@nerdenough
nerdenough / vueSetup.md
Last active June 6, 2021 17:21
macOS Setup for Vue

macOS setup for Vue

Install macOS :P

Install Homebrew

Open terminal and run the follow command to install the latest version of Homebrew. This will also install the XCode utils if you don't have them already installed.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"