#this is a test for GIST access API#
String file contents |
String file contents |
#Authentication, Logging in and Authorization in our app so far
###Authentication
Authentication in our app is fairly straightforward, at this point. In our gemfile, we require the gem 'bcrypt', and in our User model, we include the method
has secure password
. This tells the gem to look at the users table for the password_digest
column that we need for the 'salted' or encoded version of our password.
We ask a user to input a password when they create their account. They also must input a confirmation for their password. Bcrypt looks at the password and password confirmation params, and if they match, it encodes the password into an enormous string of symbols and letters, (this is based off an algorithm, and it is equal to the password originally input). The original password isn't stored anywhere. When a user logs in, Bcrypt checks the database to make sure the encoded version of what the user enters upon login matches what's on the able. If that's the case, they are authenticated and logged in.
First, I am going to take a look at the constructor function that we will use to build StudentView objects. Here is the function
function StudentView(model){
this.$el = $('<p>');
this.model = model;
}
We define two attributes on the object from the constructor function. First, we define the element ($el) attribute, and assign it to a jQuery object that will create a new paragraph element for us.
#main.js
Hoo-boy, there aren't enough gifs for this one.
var todoApp = {};
todoApp.taskNum = 0;
todoApp.taskViews = {};
#task.js
Here we are building the model objects for tasks, which can talk to the TaskView objects, but not directly to the DOM. They talk to the database for us.
function Task(data) {
console.log('model created with data:', data);
this.id = data.id;
this.completed = data.completed;
this.description = data.description;
#task_view.js
function TaskView(model){
console.log('view created with model:', model);
this.$el = $("<li>");
this.model = model;
}
This is our constructor function for TaskView objects. We can pass it a model as a parameter. The console will log the details of that model for us.
#Hosting a Rails Application on Heroku
####Prior Information
- What is the asset pipeline in Rails?
- Answer: Rails Guides - The Asset Pipeline
- Additonal information: RailsCast on the Rails Asset Pipeline
- Heroku's Rails Guide
####Push to Heroku
#!/usr/bin/env bash | |
echo -e "Welcome to WDI! This script will install a few programs that we'll be using in class. You may be prompted to enter your password. You won't see anything input when you type, but just press enter once you've entered your password" | |
# Install Homebrew | |
# piping echo to simulate hitting return in the brew install script | |
echo | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |