helpers do | |
def current_user | |
User.find_by_id(session[:user_id]) | |
end | |
def login_user(user) | |
sesson[:user_id] = user.id | |
end |
<h3>Please Log in:</h3> | |
<form name="input" action="/signup" method="post"><br> | |
First Name: <input type="text" name="new_user[first_name]"><br> | |
Last Name: <input type="text" name="new_user[last_name]"><br> | |
Email: <input type="text" name="new_user[email]"><br> | |
Password: <input type="password" name="new_user[password]"><br> | |
<input type="submit" value="Sign Up!"> | |
</form> | |
<br> | |
<hr> |
var Die = function() { | |
this.roll = function() { | |
// Math.random() generates a float, so we use | |
// Math.floor() to round down to the nearest integer | |
return Math.floor(1 + Math.random()*6); | |
}; | |
}; | |
// this says: | |
// "We're defining a new constructor function called Die" |
#For Loops
##for A for loop, as mentioned above, is useful for looping with a given number of iterations. Use it when you want to do something x times, such as changing the values in an array or counting the number of vowels in a string.
The common and fundamental syntax for a for loop in JavaScript is as follows:
for (var i = 0; i < n; i++) {
// block of code
}
#While Loops
####A while loop is the simplest type of looping operation: do something until a condition evaluates to false. Here is an example of a basic while loop:
var n = 1;
while (n <= 5) {
console.log("n is equal to " + n);
n = n + 1;
}
#=== vs. ==
The equality operator is THREE = signs, not two. JavaScript does provide a == comparison operator as well, but it performs type conversion before comparing and thus is not testing for true equality. As a rule of thumb, always use the === operator in JavaScript unless you know that you want ==.
#JavaScript Functions
var foo = function(bar) { bar + 'baz'; };
// Literally, the parts of the function:
var name = function(parameter, parameter) { body; };
When invoking a function in JavaScript the parentheses are required even if the function does not take any parameters.
, How to pull your remote branch to a different computer. In order to pull what you have to your personal computer follow this format:
git clone -b <branch> <remote_repo>
Example:
git clone -b Milan https://github.com/nighthawks-2014/ruby-flashcards-2-mvc-pattern-more-challenge.git