Possible Duplicates:
i = true and false in Ruby is true?
What is the difference between Perl's ( or, and ) and ( ||, && ) short-circuit operators?
Ruby: difference between || and 'or'
Is ||
same as or
in Rails?
Case A:
@year = params[:year] || Time.now.year
Events.all(:conditions => ['year = ?', @year])
will produce the following SQL in script/console
:
SELECT * FROM `events` WHERE (year = 2000)
Case B:
@year = params[:year] or Time.now.year
Events.all(:conditions => ['year = ?', @year])
will produce the following SQL in script/console
:
SELECT * FROM `events` WHERE (year = NULL)