Dev box
I'm a 32-year-old Ruby on Rails web developer. With the help of friends and co-workers, I've been teaching myself Rails. I worked as a Rails developer for Crowd911 in Colorado. I live in Berlin.
In my developer blog I publish a stochastic array of thoughts and ideas, lessons, mistakes, questions and attempts as answers about Rails and Ruby. I am also posting Anki cards that I used to help myself study. In my view most knowledge is about practice. If you have thoughts, questions, ideas, corrections, arguments, feel free to email me at henryvw@gmail.com.

Symbolic links "ln -s"

Symbolic links are a way to link a file to another in a Unix OS.

For example,

ln -s /usr/local/apache/logs   ./logs

would point a link from ./logs to /usr/local/apache/logs. When the computer goes to access ./logs, it will be pointed to /usr/local/apache/logs.

 

Read More

Simple Booleans and IF

Simple Booleans and IF

With very simple boolean statements, in Ruby you can put them on one line:

method IF boolean

puts "Its true!" if true

Ternary Conditional Expression

boolean ? Do this if true : Do this if false

Boolean, expression to evaluate if the boolean is true, expression to evaluate if the boolean is false.

 

puts 3 < 4 ? „3 is less than 4!“ : „3 is not less than 4.“

Read More

CRUD - create, read, update and delete

CRUD - create, read, update and delete

 

CRUD are the 4 verbs many programs that deal with data know and enact.  You’ll see this framework in everything from API calls to Rails frameworks!

Read More

Adding to arrays and hashes in Ruby

For Arrays, use Ruby Push

Push - add to an array!

array = [ 1,2,3 ]

array.push(4)

 

#=> array == [1,2,3,4]

 

For Hashes, use Ruby Merge

Merge - or merge! … add to a hash!

hash = { :a => ‚a‘}

hash.merge! {:b => ‚b‘}

#=> hash == {

:a => ‚a‘ 

:b => ‚b‘

}

Add VARIABLE to Hash:

hash = { }

hash_key = gets.chomp

hash_value = gets.chomp

hash [hash_key] = hash_value

 

Delete Variable from Hash:

 

hash.delete(variable)

Read More

Ruby Case Statement/Syntax

The Case Statement is an alternative to if, elsif, elsif, elsif, etc.

Instead you declare the beginning of a Case statement:

case programming_language

when „JS“

      puts „Websites!“

when „Python“

      puts „Science!“

when „Ruby“

     puts „Web apps!“

else

     puts „I don’t know!“

 

end

Read More






Footerfull