- 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
| For those of you finding this in 2018, with tmux 2.6, you don't need the reattach-to-user-namespace gymnastics anymore. This is all I need with iTerm2 (3.1.5), tmux (2.6) and macOS High Sierra (10.13.2). | |
| In iTerm 2 preferences, first tab "General", enable "Applications in terminal may access clipboard". | |
| # tmux 2.6 doesn't need the 'reattach-to-user-namespace' gymnastics | |
| setw -g mode-keys vi | |
| bind-key -T edit-mode-vi Up send-keys -X history-up | |
| bind-key -T edit-mode-vi Down send-keys -X history-down | |
| bind-key -T copy-mode-vi v send -X begin-selection | |
| bind-key -T copy-mode-vi [ send-keys -X begin-selection |
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
| let systemIcons = [ | |
| "circle", | |
| "square", | |
| "arrow.left", | |
| "arrow.up", | |
| "arrow.right", | |
| "arrow.down", | |
| "arrow.left.and.right", | |
| "arrow.up.left", | |
| "arrow.up.right", |
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
| body { background: #222; color: #e6e6e6; } | |
| a { color: #949494; } | |
| a:link, a:visited { color: #949494; } | |
| a:hover, a:active, a:focus { color: #c7c7c7; } | |
| hr { border-bottom: 1px solid #424242; border-top: 1px solid #222; } |
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
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <!-- Required meta tags --> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
| <title>Hello, world!</title> | |
| </head> | |
| <body> |
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
| module SoftDeletable | |
| extend ActiveSupport::Concern | |
| included do | |
| default_scope { where(deleted_at: nil) } | |
| scope :deleted, -> { unscope(where: :deleted_at).where.not(deleted_at: nil) } | |
| end | |
| def delete | |
| self.touch(:deleted_at) if has_attribute? :deleted_at |
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
| " A minimal vimrc for new vim users to start with. | |
| " | |
| " Referenced here: http://www.benorenstein.com/blog/your-first-vimrc-should-be-nearly-empty/ | |
| " Original Author: Bram Moolenaar <Bram@vim.org> | |
| " Made more minimal by: Ben Orenstein | |
| " Last change: 2012 Jan 20 | |
| " | |
| " To use it, copy it to | |
| " for Unix and OS/2: ~/.vimrc |
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
| body { | |
| background-color: #fff; | |
| color: #333; | |
| margin: 33px; | |
| font-family: verdana, arial, helvetica, sans-serif; | |
| font-size: 13px; | |
| line-height: 18px; | |
| } | |
| p, ol, ul, td { |
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
| # config/routes.rb | |
| resource :ghost, only: [:create, :destroy] | |
| # app/controllers/ghosts_controller.rb | |
| class GhostsController < ApplicationController | |
| def create | |
| session[:admin_id] = current_user.id | |
| user = User.find(params[:user_id]) | |
| sign_in user |
NewerOlder
