Organize code in models using the following convention:
- Constants
- Associations
- Validations
- Callbacks
- Other macros (Devise, FriendlyId, etc.)
- Scopes
# Inside controller action.
send_data data, filename
Make the container of an image keep the size and aspect ratio of the image.
.intrinsic-ratio-container {
position: relative;
padding-bottom: 56.285714%; /* This defines the aspect ratio. */
height: 0;
color: #ddd; /* Same color as background-color to hide the image description text. */
git reset HEAD^ path/to/file/to/revert
git commit --amend
Source: https://superuser.com/a/229296
Note: Using StandardJS rules.
function * range(start, end, step = 1) {
while (start <= end) {
yield start
# frozen_string_literal: true | |
# Alerts of SQL queries made within views. | |
# | |
# https://www.driftingruby.com/episodes/improving-partial-loading-performance | |
module StrictQueries | |
class SQLWithViewError < StandardError; end | |
module Concern | |
extend ActiveSupport::Concern |
# frozen_string_literal: true | |
class ObjectNameDecorator < SimpleDelegator | |
delegate :class, :is_a?, to: :__getobj__ | |
def self.collection(objects) | |
objects.map { |group| ObjectNameDecorator.new(object) } | |
end | |
private |