git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.
For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.
Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.
Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.
This method does not add your OAuth token to Gemfile.lock
. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying.
config.assets.precompile += [ | |
# precompile any CSS or JS file that doesn't start with _ | |
/(^inline[^_\/]|\/[^_])[^\/]*.(js|css)$/, | |
... |
class MigrateHstoreToJson < ActiveRecord::Migration | |
def up | |
rename_column :posts, :data, :data_hstore | |
add_column :posts, :data, :jsonb, default: {}, null: false, index: { using: 'gin' } | |
execute 'UPDATE "posts" SET "data" = json_object(hstore_to_matrix("data_hstore"))::jsonb' | |
remove_column :posts, :data_hstore | |
end | |
def down | |
rename_column :posts, :data, :data_jsonb |
module ActiveRecord | |
module RailsAdminEnum | |
def enum(definitions) | |
super | |
definitions.each do |name, values| | |
define_method("#{ name }_enum") { self.class.send(name.to_s.pluralize).to_a } | |
define_method("#{ name }=") do |value| | |
if value.kind_of?(String) and value.to_i.to_s == value |
module ActiveJobRetryControlable | |
extend ActiveSupport::Concern | |
DEFAULT_RETRY_LIMIT = 5 | |
attr_reader :attempt_number | |
module ClassMethods | |
def retry_limit(retry_limit) | |
@retry_limit = retry_limit |