String interpolation with single and double quotes dealing with escape characters

08/14/15  Public, Testing / TDD, Ruby General

This expectation does not recognize/interpolate the @volunteer.phone_number:

expect(response.body).to include('<Message to="#{@volunteer.phone_number}">Anybody home?</Message>')

By using Ruby programming *alternate double quo...

1 vote - harrylevine

Adding a unique constraint to a Postgres database column

08/11/15  Public, Databases

class AddUniqueConstraintToVolunteerPhoneNumber < ActiveRecord::Migration
  def change
    reversible do |dir|
      dir.up do
        execute 'ALTER TABLE volunteers ADD CONSTRAINT unique_phone UNIQUE (phone_number)'
      end
    ...

1 vote - harrylevine

Bring down a new Git branch from origin repo to your local repo

08/08/15  Public, Git

If there is a new branch out on the origin repo (in GitHub), and you do no have a copy of that branch in your local remote repo, here is what you will run to bring that copy down to your local remote repo:

$ git checkout master
$ git ...

1 vote - harrylevine

Add security with HTTPS

07/20/15  Public, Rails General

Simply use config.force_ssl = true in your environment configuration.

# config/application.rb
module MyApp
  class Application < Rails::Application
    config.force_ssl = true
  end
end

You can also selectively enable http...

1 vote - harrylevine

Testing for page content in an RSpec controller spec

07/19/15  Public, Testing / TDD

With RSpec, in a controller spec, you can still test for page content by adding render_views under the
describe block, and using expect(response.body).to have_content('blah blah blah')

require 'rails_helper'
require 'support/d...

1 vote - harrylevine

CSS stylesheet not being included in the application.css tree

07/16/15  Public, Other Languages

If the global application.css isn’t attempting to include per-view stylesheets, add something like this to the top of your view:

<%= stylesheet_link_tag 'support_calls/dashboard' %>

In this example, the path to the view file is...

1 vote - harrylevine

Git squash and merge two commits into one

08/13/15  Public, Git

http://stackoverflow.com/questions/2563632/how-can-i-merge-two-commits-into-one

$ git rebase --abort
$ git rebase --interactive HEAD~2

If you want to squash all of the commits back to origin/master run: $ git rebase -i master

You...

1 vote - harrylevine

Using git bisect to troubleshoot

06/30/15  Public, Troubleshooting

Occasionally, something added to a gem used by one of your projects will break your application. Finding out where, when, and how it broke can be a challenge...

https://mojolingo.com/blog/2013/using-git-bisect-to-troubleshoot-ruby-gems/

1 vote - harrylevine

Create a link from GitHub that brings you directly to a specifically highlighted set of lines in a file

06/24/15  Public, Git

  1. Navigate to the file in the GitHub repo
  2. Click on the line numbers you want to highlight (use the shift key to highlight multiple lines)
  3. Copy the link from the address bar

1 vote - harrylevine