def is_a_number?(s)
s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil? false : true
end
operand what it does
<< append (in context of strings, arrays, IO); shift position of bits in Bignum and Fixnum
>> shift position of bits in Bignum and Fixnum
~ bitwise NOT (high-presendence)
& bitwise AND (medium-presendence)
| bitwise OR (medium-presendence)
^ bitwise XOR (medium-presendence)
** exponent
+ addition
- subtraction
* multiplication
/ division
% modulo operator
  1. Go to script/console to open ruby in interactive mode. script/console loads your environments (everything in environment.rb and all your plugin and gem initializers), so you basically have access to all your models right from interactive ruby mode (IRB).
  2. Remember use of the p (or its alias puts) command to print stuff to the output buffer. This is useful for testing in IRB mode, inside of a test, or other places where you have an output buffer. If you're running mogrel, your output goes to the terminal. If you're running Passenger with Apache, check your apache error_log for the output.

A method defined on a model that ends with = is an assignment method, so when ActiveRecord is trying to save an attribute to this model, you can define a custom action to perform the save. Useful, for example, when passing a hash to this model for some list of things that is not part of active record.

Mar 052009

Some handy information about working with those less-than-percent sign things that appear in Emulated Ruby, or .rhtml files.

example what it does
<% ... %> evaluate/execute ruby code
<%= ... %> evaluate & return to buffer (result will be included in output)
<%- ... %> strip whitespace before tag
<% ... -%> strip whitespace after tag
© 2012 Tech Notes Suffusion theme by Sayontan Sinha