- See more at: http://blogtimenow.com/blogging/automatically-redirect-blogger-blog-another-blog-website/#sthash.YsVbCxL0.dpuf Journey to Becoming a Web Developer: rails
Showing posts with label rails. Show all posts
Showing posts with label rails. Show all posts

Tuesday, February 11, 2014

Single Table Inheritance

I'm currently building an app that needs to have a base model and sub-models. I wasn't sure how to do that, so I did some research online and found STI or Single Table Inheritance.  The idea behind it is that the sub-models will inherit from the base model, so it will be able to use all of the attributes of the base model.  In the migration of the base model you must have a type field. This is how rails knows that other models will be inheriting from this model.  In the example below the singer and dancer models will inherit from the entertainer model, so now we can create a new entertainer object an be able to use the attributes associated with entertainer on that object.










Sunday, February 2, 2014

Lexical Scoping


In the example above I was able to find all of the even numbers in an array using lexical scoping and the .filter method.  Because I defined the getNumbers function inside of the parent function getEvenNumbers the child function getNumbers knows about numbersArray.  So when I call the .filter method it will iterate through each element in the array passed to numberArray then pass  it to the callback function getNumbers which checks to see if each element is divisible by 2.  .filter will return the results in a new array.


Monday, January 20, 2014

Anatomy of a JavaScript function

JavaScript functions are very different from Ruby methods. While reading Intro to Functions I became quite confused because I am so used to the way methods work in Ruby. I did understand some of it. Here is what I observed.

In JavaScript defining properties of pure functions is that they always return the same values when given the same arguments.
A function is built by first using the word function then the name we want to call the function followed by the names of the argument/s in parenthesis.  Last would be the body of the function. Ex:






Return is used to define the value that the function returns. If there is no expression after return the function will return undefined


In this example both the top level variable and the local variable are named variable.  The function printVariable is called inside of the function test. Even though printVariable was called inside of test the local variable is not available to the printVariable function.


Lexical Scoping is when a variable visibility is determined by the functions placement in the program text. Both local variables and top-level variables are visible. In the example because the child function was defined in the parent function the local variable from the parent function is the only variable visible to it.



Sunday, January 19, 2014

Differences between JavaScript and Ruby

Next week at the Flatiron School we will be learning JavaScript. We were asked to blog about some the differences. Here is what I have observed.

Values 
In JavaScript datatypes such as string or number are called values while in Ruby they are just called data types.  Other values in JavaScript are booleans, objects, and, undefined values. Operators in JavaScript are used in the same way as they are in Ruby.  One operator in JavaScript that I learned about is typeof. It can give you the type of value something is. Ruby has something similar which is the method class which can give you the class of an object. 


Variables
JavaScript and Ruby both hold data in variables. In JavaScript syntax var is used before the variable name and in Ruby the variable name alone is used. 
JavaScript




Ruby





 Functions in JavaScript are similar to methods in Ruby.  In JavaScript alert is a variable that contains a function that takes one parameter and shows the result of the expression.  This example  in JavaScript will return the largest number in the argument. 




Math.max is the function that returns 4. In Ruby the method that does this is called max. The same example in Ruby would look like this:




Loops
Loops are used in Ruby and JavaScript in the same way, but the syntax is different. I will show an example of how a while loop looks in JavaScript vs. Ruby.

JavaScript

Ruby








Sunday, October 20, 2013

Accepted into the Flatiron School!

Hello all.  On Friday October 11th I found out I was accepted into the Flatiron School Fellowship program. I'm really excited and I hope that I excel while I'm here. Since then I've been trying to get the prework done. Currently I'm doing the Ruby Foundations on Treehouse. I will also try to write a post daily. Until next time.

Wednesday, August 7, 2013

Ruby

I'm trying to get a better grasp of Ruby so along with reading Zed Shaw's book I've been doing the lessons on RubyMonk.com. RubyMonk is a pretty good site for learning Ruby, so I'd recommend it. I'm still not the best I Ruby, but I've definitely gotten better. Practice makes perfect. I still haven't solved my Michael Hartl's tutorial issue. Sunday I plan on going to hacker Meetup, so I hope I can get help there. I really can't wait to get back into the tutorial. Once I finish it I want to work on my own Rails site. Not sure what it will be as yet.  That's all for now.

Sunday, August 4, 2013

Introduction

Hello! My name is Keturah, I live in Brooklyn, NY and I'm studying to become a junior rails developer. I got the idea to create this blog from Josh Kemp. He was on this same journey last year and he currently has a job as a junior developer. His story has definitely kept me motivated. If you are interested in becoming a rails developer you should check his blog out Josh Kemp. Right now I'm doing Michael Hartl's tutorial, "Learn Ruby the Hard Way" by Zed Shaw, and Chris Pine's "Learn to Program". All three are great learning materials. Currently I'm stuck on chapter 8 of MH's tutorial. I keep getting this error: rails_projects/sample_app/app/controllers/application_controller.rb:3:in `<class:ApplicationController>': uninitialized constant ApplicationController::SessionsHelper (NameError). So far I haven't been able to solve this issue. I'm thinking maybe it's a formatting thing.  I'll see if someone on Stack Overflow or someone at a hacker Meetup can help. Recently I have finished the Ruby 4 Kids airplane laser game, and the ball game. I'm going to push them up to GitHub once I'm done making my own little changes to them. I'm also going to create my own Ruby game. I so excited about all of this. I really want to become junior developer. That's all for now