git branch --set-upstream-to <remote-branch>
# example
git branch --set-upstream-to origin feature-branch
# show up which remote branch a local branch is tracking
git branch -vvsets the default remote branch for the current local branch.
| Adding Bootstrap to Rails 7 | |
| Reference: https://www.linkedin.com/pulse/rails-7-bootstrap-52-importmap-md-habibur-rahman-habib/ | |
| INSTRUCTIONS | |
| 1. Add the following to Gemfile: | |
| gem "bootstrap" | |
| gem "sassc-rails" |
| # This is a thin wrapper of the Simple Form builder. It delegates rendering the resulting form fields to Simple Form | |
| # but typically amends the Tailwind classes of the various elements in the field layout. It tightly integrates with the | |
| # unstyled wrapper (aka `:plain`) Simple Form configuration (see `simple_form.rb`). The methods support the same syntax | |
| # as the original Simple Form methods but enhance it to support replacing defaylt Tailwind claseses. | |
| class Builders::TailwindFormBuilder < SimpleForm::FormBuilder | |
| # This is the basic method for rendering `<input>` tags and their variants. | |
| def input(attribute_name, options = {}, &block) | |
| # The default Tailwind classes for the various parts of the Simple Form wrapper layout. | |
| input_class = "block w-full sm:text-sm ... #{'text-gray-500 bg-gray-50' if options.dig(:input_html, :disabled)}" |
| require 'rails_helper' | |
| RSpec.describe MyWorker, type: :job do | |
| include ActiveJob::TestHelper | |
| let(:sqs_msg) { double AWS::SQS::ReceivedMessage, | |
| id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e', | |
| body: 'test', | |
| delete: nil } | |
| class API::BaseController < ApplicationController | |
| def index | |
| render json: { active: true } | |
| end | |
| def authenticate | |
| if user = User.authenticate(request.headers['X-AUTH-TOKEN']) | |
| sign_in(user, store: false) |
git branch --set-upstream-to <remote-branch>
# example
git branch --set-upstream-to origin feature-branch
# show up which remote branch a local branch is tracking
git branch -vvsets the default remote branch for the current local branch.
| # db/migrations/xxxxxxxxxxxxxx_create_image_attachment.rb | |
| class CreateImageAttachments < ActiveRecord::Migration[5.0] | |
| def change | |
| create_table :image_attachments do |t| | |
| t.belongs_to :imageable, polymorphic: true | |
| t.attachment :data | |
| t.boolean :default, default: false | |
| t.timestamps | |
| end |
It's important to note that running this reset will drop any existing data you have in the application
heroku restartheroku pg:reset DATABASE (no need to change the DATABASE)heroku run rake db:migrateheroku run rake db:seed (if you have seed)One liner
Run rails new --help to view all of the options you can pass to rails new:
$ bin/rails new --help
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/eliot/.rbenv/versions/2.2.0/bin/ruby
You need to do this
<%= f.input :message, :input_html => {:rows => 10} %>
<%= f.input :description, :as => :text, :input_html => { 'rows' => 5, 'cols' => 10 } %>| function OnBlurComponent({ onBlur }) { | |
| const handleBlur = (e) => { | |
| const currentTarget = e.currentTarget; | |
| // Check the newly focused element in the next tick of the event loop | |
| setTimeout(() => { | |
| // Check if the new activeElement is a child of the original container | |
| if (!currentTarget.contains(document.activeElement)) { | |
| // You can invoke a callback or add custom logic here | |
| onBlur(); |