Web Coding in Ruby
I know very little about Ruby. Like Python, it lacks curly braces. Like Basic and Pascal, it uses the keyword end to end a control block (loop). I am still learning.
I am learning that some function calls require the opening parenthesis to be immediately after the function name without white space. This is because the parentheses are optional, and the interpreter sees the parentheses and contents as a tuple if there is intervening white space. Unfortunately, this is not the "look" I like in my code; but I can live with it.
To make the CGI work, I needed to add this .htaccess file:
OPTIONS Indexes AddHandler cgi-script .rb Options +ExecCGI
I had to install the Ruby mysql gem and make a symbolic link as follows. The detailed instructions are in one of the links on this page. Because of this extra installation, I don't know if other servers will have this Ruby-MySQL support.
$ sudo gem install mysql $ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib \ /usr/lib/libmysqlclient.18.dylib
Useful links
Because I'm new to Ruby, I had to look up everything!
Strings
- Convert a number to a string
- Convert string to integer
- String concatenation
- Quoting long strings or string that have quote characters inside
- Quote multiline indented strings
- Capitalize / ucfirst()
- File.basename
- Substrings
- Sprintf
- Printf
- Ruby String functions: search and replace - gsub
- Ruby trim
Files
MySQL
- Ruby MySQL Tutorial: including installation of the Gem
- Library not loaded: libmysqlclient.16.dylib error