Skip to content

Instantly share code, notes, and snippets.

View Colo-Codes's full-sized avatar
💎
Learning Ruby on Rails

Damian Demasi Colo-Codes

💎
Learning Ruby on Rails
View GitHub Profile
@jonurry
jonurry / 4-3 Eloquent Javascript Solutions.js
Last active July 17, 2022 10:57
4.3 A List (Eloquent JavaScript Solutions)
function arrayToList(array) {
let result = {};
if (Array.isArray(array)) {
let currListItem = result;
for (let item of array) {
let newListItem = {
value: item,
rest: null
};
if (typeof currListItem.rest === 'undefined') {
@jonurry
jonurry / 4-1 Eloquent Javascript Solutions.js
Last active December 28, 2023 13:27
4.1 Sum of a Range (Eloquent JavaScript Solutions)
// step parameter is optional
// if step is not passed in,
// and start is less than or equal to end,
// then step = 1, else step = -1
function range(start, end, step = start <= end ? 1 : -1) {
let result = [];
// loop iterates up for positive step values
// and iterates down for negative step values
for (let i = start; step >= 0 ? i <= end : i >= end; i+=step) {
result.push(i);
@mdang
mdang / RAILS_CHEATSHEET.md
Last active May 13, 2024 14:04
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@iangreenleaf
iangreenleaf / gist:b206d09c587e8fc6399e
Last active May 5, 2024 14:52
Rails naming conventions

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do