df command

The df command, which stands for “disk filesystem”, shows a summary of the available and used disk space on your Linux system. With the -h option it shows the disk space in “human readable” form, which in this case means, it gives you the units along with the numbers. For example,

df -h

will output a table with four columns. The first column contains the file system path, which can be a reference to a hard disk or another storage device, or a file system connected through the network. The second column shows the capacity of that file system. The third column shows the available space, and the last column shows the path on which that file system is mounted. The mount point is the place in the directory tree where you can find and access the that file system.

Advertisements

Calling multiple redirects or renders

An action may contain only a single render or a single redirect. Attempting to try to do either again will result in a DoubleRenderError:

def do_something
  redirect_to :action => "elsewhere"
  render :action => "overthere" # raises DoubleRenderError
end

If you need to redirect on the condition of something, then be sure to add “and return” to halt execution.

def do_something
  redirect_to(:action => "elsewhere") and return if monkeys.nil?
  render :action => "overthere" # won't be called if monkeys is nil
end

default arguments

When call a method with blank value in default arguments/with no argument in the position of default argument, the method uses the default value automatically….This is like “overload” in C++

What’s the idiom in Ruby when you want to have a default argument to a function, but one that is dependent on another parameter / another variable? another parameter / another variable?

def foo(a, l = a.size) end