Install Package Control for easy package management.
- Open the console with
Ctrl+`
- Paste in the following:
Install Package Control for easy package management.
Ctrl+`
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
/* jshint strict: false */ | |
/* globals require, console */ | |
var gulp = require('gulp'); | |
var exit = require('gulp-exit'); | |
var browserify = require('browserify'); | |
var watchify = require('watchify'); | |
var babelify = require('babelify'); | |
var source = require('vinyl-source-stream'); |
source 'https://rubygems.org' | |
gem 'mechanize' |
// source: http://stackoverflow.com/questions/16491758/remove-objects-from-array-by-object-property | |
// we have an array of objects, we want to remove one object using only the id property | |
var apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}]; | |
// get index of object with id:37 | |
var removeIndex = apps.map(function(item) { return item.id; }).indexOf(37); | |
// remove object | |
apps.splice(removeIndex, 1); |
# app/controllers/api/v1.rb | |
class Api::V1 < Grape::API | |
class Grape::Middleware::Error | |
def error_message(code, text) | |
{ | |
:error => { | |
:code => code, | |
:message => text | |
} |
Rails 5.0 Rails 5.1+ changed? → saved_change_to? _was → _before_last_save changed? → saved_changes? changed_attributes → saved_changes.transform_values(&:first)
Model callbacks behavior After Rails 4.x release, some changes were made on callbacks to split update on the model before and after writing data to the database. We had to be careful to use the correct helpers: _changed? for after_save callbacks, and previous_changes[:] for after_commit callbacks: