README.md always updatedActiveRecord models:
class ModelName < ApplicationRecord
# includes
include ModuleName
# enums
enum type: [:a, :b, :c, :d]
# relationships
belongs_to :parent
has_many :children
# attributes
attr_accessor :fieldname
# validations
validates :name, presence: true
# scopes
scope :deleted, -> { where(deleted: true) }
# callbacks
before_save :do_something
end
app/lib/
libNounVerber
CreditCardChargerCreditCardCharger.new(processor: :braintree)call and send data parameters to this
CreditCardCharger.new(processor: braintree).call('4111111111111111','123','11/28')Result object which can encapsulate the success, errors and instance
result = CreditCardCharger.new(processor: :Braintree).call(card_details)
if result.success?
Rails.log("Successful trans: #{result.transaction}")
else
Rails.error("Error in transaction: #{result.errors}")
end
app/services folder (see custom code above)app/jobsperform parameters to a minimum. Ideally, pass in [model].id as parameter and query within the job. (This also allows the job to fail if record is not found)app/ folder as this is autoloaded by default.
app/decoratorsapp/utilitiesapp/composers1 PORO = Plain Old Ruby Object.
The distinction between a PORO (which stands for Plain Old Ruby Object) and a not-PORO is not a technical one. All objects are technically Ruby object. Instead, the term PORO is sometimes used when talking about large frameworks like Rails which tend to use “big”, “complex” objects like ActiveRecord models for much of its logic. These large objects tend to contain a large amount of logic and defined behavior.