If you're using Rails, you'll need to change the required version of factory_girl_rails:
gem "factory_girl_rails", "~> 3.0"| #Session controller provides a token | |
| #/controllers/api/sessions_controller.rb | |
| class Api::SessionsController < Devise::SessionsController | |
| before_filter :authenticate_user!, :except => [:create] | |
| before_filter :ensure_params_exist, :except => [:destroy] | |
| respond_to :json | |
| def create | |
| resource = User.find_for_database_authentication(:email => params[:user_login][:email]) | |
| return invalid_login_attempt unless resource |
| // Change the default message of jquery validation | |
| jQuery.extend(jQuery.validator.messages, { | |
| required: "This field is required.", | |
| remote: "Please fix this field.", | |
| email: "Please enter a valid email address.", | |
| url: "Please enter a valid URL.", | |
| date: "Please enter a valid date.", | |
| dateISO: "Please enter a valid date (ISO).", | |
| number: "Please enter a valid number.", | |
| digits: "Please enter only digits.", |
| /* Delete the tables if they already exist */ | |
| drop table if exists Movie; | |
| drop table if exists Reviewer; | |
| drop table if exists Rating; | |
| /* Create the schema for our tables */ | |
| create table Movie(mID int, title text, year int, director text); | |
| create table Reviewer(rID int, name text); | |
| create table Rating(rID int, mID int, stars int, ratingDate date); |
| =begin | |
| Tested with ruby 1.8.7 on a Debian machine, with my own gmail account. | |
| ruby -rubygems "from name" "from email" "to name" "to email" "subject" "body" | |
| =end | |
| require 'net/smtp' | |
| require 'tlsmail' | |
| Net::SMTP.enable_tls OpenSSL::SSL::VERIFY_NONE | |
| $SERVER = 'smtp.gmail.com' |
| # | |
| # 2 - REVERSAL | |
| # | |
| # The quickest way to reverse an array is to swap elements at either end, and repeat | |
| # while moving up from the left and down from the right. | |
| # | |
| # [ a b c d e f ] | |
| # [ f a ] - Step 1 we switched A[0] with A[-1] | |
| # [ e b ] - Step 2 we switched A[1] with A[-2] | |
| # [ d c ] - Step 3 we switched A[2] with A[-3] |
Citations for the course on Udemy. Course Link