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.

Ruby - the Main object, which contains methods like puts, return, print

Every method needs an object. 

But what about puts, return, print, etc.?

Main is the special object that contains the free-standing methods like puts, return, print, etc. 

Read More

When you type Ruby helloword.rb into terminal, what is the Ruby command actually doing?

Why, it’s the Ruby Interpreter of course.  The Ruby Interpreter examines the Ruby code that you’ve typed into your editor, and it translates it into machine code instructions for the computer.  One advantage is that, it enables you to modify the program while it’s running; the disadvantage is that it runs more slowly than a compiled program.

Read More

Ruby - Difference between Parameters and Arguments

Parameters and Arguments
A parameter is what you define when you create a method that accepts an argument.  

Defining the Method:

def Method(parameter

functions

end

 

Calling the Method:

Method(argument)

 

So, an argument is what fills the parameter.  One might compare a parameter to a variable, and an argument to what you stick inside the variable. 

Read More

Ruby basic notes - Classes, Constructors, and Symbols

Ruby

**Classes are like factories that generates objects - i.e. instances of that class**

**An object is a combination of „state“ or attributes (e.g. quantity and product ID) and methods that use that state (e.g. calculate total cost of the line item).**

A Constructor is a special method for a class.  The standard constructor is ().new.

summer_dress = LineItem.new

summer_dress.price = 5.00

summer_dress.quantity = 1

summer_dress.id = 443213

How do Methods work?

When you call a method on an object, you trigger a message to the object.  The message contains the method’s name, along with any parameters the method may need.  When an object receives the message, it looks into its own class for a corresponding method.  

 

A Symbol in Rails ( :symbol ) is the simplest Ruby object you an create.  It’s just a name with an ID.  It’s printed as a colon followed by a name.  Symbols are useful because the name is just one object, with just one ID.  Whereas every string, even if its identical, has a new ID.  So symbols save memory. 

Read More

Great developer tools: pencil and paper

Great developers use pencil and paper. They write down your problems as questions.

Tonight I noticed that the comments worked in the index, but not in the show.  I was stumped. Then, I took the time to write the problem down.  Just simply, write down the question on a sheet of paper.  Pretty soon I noticed that there was a difference with all the other post variables in show - they were instance variables of post, @post, rather than just „post.“  As soon as I converted the tag to an instance variable, it worked. 

The power of writing down questions, problems, etc, and thinking through them, is miraculous.  I am grateful for this recognition.  Sometimes, too, I notice, one’s mind is weary, one goes down the rathole, and one wants to simply press on and find an obvious solution.  

 

It can take a bit of Grit to Question.

Read More






Footerfull