The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the
# app/filters/base_filter.rb | |
class BaseFilter | |
include ActiveModel::Model | |
include ActiveModel::Attributes | |
def initialize(session) | |
@_session = session | |
super(@_session.fetch(:filters, {})[filter_resource_class]) | |
end |
# app/models/board.rb | |
class Board < ApplicationRecord | |
has_many :embeds | |
end |
class MembershipProduct < ApplicationRecord | |
include Sellable | |
# Other stuff... | |
end |
import { Controller } from "stimulus"; | |
export default class extends Controller { | |
static targets = ["source"]; | |
copy() { | |
const range = document.createRange(); | |
window.getSelection().removeAllRanges(); |
It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media
This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.
By default, Rails applications build URLs based on the primary key -- the id
column from the database. Imagine we have a Person
model and associated controller. We have a person record for Bob Martin
that has id
number 6
. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6
here, is called the "slug". Let's look at a few ways to implement better slugs.
This list is based on aliases_spec.rb.
You can see also Module: RSpec::Matchers API.
matcher | aliased to | description |
---|---|---|
a_truthy_value | be_truthy | a truthy value |
a_falsey_value | be_falsey | a falsey value |
be_falsy | be_falsey | be falsy |
a_falsy_value | be_falsey | a falsy value |
## /etc/openresty/nginx.conf | |
user www-data; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
lua_shared_dict auto_ssl 1m; |