- 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 newfirst 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 tailwindas an option on therails newcall 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 newwill 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 --devcontainerbut 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
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /* | |
| smtpd.js is SMTP server written for node.js | |
| MIT License | |
| */ | |
| var tcp = require('tcp'); | |
| var sys = require('sys'); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'socket' | |
| require 'syslog' | |
| require 'logger' | |
| require 'hoptoad_notifier' | |
| # TcpSyslog is used are a dead-simple replacement for | |
| # syslog ruby libs. None of them is able to send logs | |
| # to a remote server, and even less in TCP. | |
| # | |
| # Example: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ["http://internal/", "http://external/"].each do |server| | |
| uri = URI.parse(server) | |
| God.watch do |w| | |
| w.name = "httpmon_#{uri.host}" | |
| w.interval = 10.seconds | |
| w.start = "echo 'start'" | |
| w.stop = "echo 'stop'" | |
| w.lifecycle do |on| | |
| on.condition(:http_response_code) do |c| | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env ruby | |
| ENV["RAILS_ENV"] ||= 'test' | |
| require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT) | |
| start_time = Time.now | |
| puts "Starting CouchDB Benchmark..." | |
| 100000.times do |n| | |
| Person.new(:first_name => "Couch_#{n}", :last_name => "Man_#{n}").save | |
| end | |
| puts (Time.now - start_time) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | rails_root = "/data/github/current" | |
| 20.times do |num| | |
| God.watch do |w| | |
| w.name = "dj-#{num}" | |
| w.group = 'dj' | |
| w.interval = 30.seconds | |
| w.start = "rake -f #{rails_root}/Rakefile production jobs:work" | |
| w.uid = 'git' | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class ActiveRecord::Base | |
| def self.find_values opts | |
| sql = self.send(:construct_finder_sql, opts) | |
| self.connection.select_values(sql) | |
| end | |
| end | |
| >> Tagging.find_values(:select => :taggable_id, :limit => 30, :order => 'tagged_at asc') | |
| => ["1", "3", "6", "6", "6", "10", "10", "10", "11", "11", "11", "10", "10", "10", "10", "10", "13", "13", "13", "13", "13", "13", "15", "15", "15", "15", "15", "15", "15", "15"] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'rubygems' | |
| require 'sinatra' | |
| require 'redis' | |
| # To use, simply start your Redis server and boot this | |
| # example app with: | |
| # ruby example_note_keeping_app.rb | |
| # | |
| # Point your browser to http://localhost:4567 and enjoy! | |
| # | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'redis' | |
| module Nanite | |
| class State | |
| include Enumerable | |
| # this class encapsulates the state of a nanite system using redis as the | |
| # data store. here is the schema, for each agent we store a number of items, | |
| # for a nanite with the identity: nanite-foobar we store the following things: | |
| # | 
NewerOlder