random rails/ruby questions for a nooby, much appreciated.
Confused as to what the second ‘?’ means in the line:
@page ||= params[:page].blank? ? 1 : params[:page].to_i
In init.rb files, what does FILE do really?
require File.join(File.dirname(__FILE__), "rails", "init")
The first ? is part of the method name, a convention used for methods that return a boolean result.
The second ? is the inline conditional operator:
is equivalent to
__FILE__is a kernel function that returns the filename of the current file.File.dirname(__FILE__)would just return the directory name of the current file, andFile.joinis the same asArray#joinwith the OS specific directory seperator (/on Linux/OSX and\on Windows)