⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true
and false
. In Python, for example, they're written as True
and False
. But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.).
This outlines how this works in Ruby, with some basic examples from Python and JavaScript, too. The idea is much more general than any of these specific languages, though. It's really a question of how the people designing a programming language wants booleans and conditionals to work.
If you want to use or share this material, please see the license file, below.
## Prepare ################################################################### | |
# Remove RVM | |
rvm implode | |
# Ensure your homebrew is working properly and up to date | |
brew doctor | |
brew update | |
## Install ################################################################### |
#Simple Authentication with Bcrypt
This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.
The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).
You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault
##Steps
.factory('TokenHandler', function() { | |
var tokenHandler = {}; | |
var token = "none"; | |
tokenHandler.set = function( newToken ) { | |
token = newToken; | |
}; | |
tokenHandler.get = function() { | |
return token; |
function consumer() { | |
return new oauth.OAuth( | |
"https://twitter.com/oauth/request_token", | |
"https://twitter.com/oauth/access_token", | |
keys.twitterConsumerKey, | |
keys.twitterConsumerSecret, | |
"1.0A", | |
"http://localhost:3000/sessions/callback", | |
"HMAC-SHA1" | |
); |
// Include our plug-ins | |
var gulp = require('gulp'); | |
var mainBowerFiles = require('main-bower-files'); | |
var exists = require('path-exists').sync; | |
// Create some task | |
gulp.task( 'copy-bower-dep', function() { | |
// Replace files by their minified version when possible | |
var bowerWithMin = mainBowerFiles().map( function(path, index, arr) { |
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |