July 26 2010 by
Ryan Carter in
Ruby |
To convert a string or other object into an integer (number) do this: "23".to_i This will produce 23 (as a number) If you do something like this: "Hello".to_i You will get 0 returned, because Ruby can’t understand that object and translate it into a number.
July 26 2010 by
Ryan Carter in
Ruby |
To convert a number to a string in Ruby, do this: 40.to_s
photo credit: Vagabond Shutterbug If there are things you want to appear on every page of your website, built in CakePHP, you will want to use a layout. I generally use one layout for header, footer, search, and other static elements. You can use multiples, but most of the time you won’t need more than [...]
Ruby Logo by hongiiv Today I am starting to learn Ruby, and that so I can next learn Ruby on Rails. I have flirted with the RoR language, been a long-time fan, but today I become a first-time caller. I am tired of being on the outside looking into the red-tinted party in the hizouse. [...]
July 20 2010 by
Ryan Carter in
Rails |
For a list of rake commands, fire up the command line and type: rake -t
Enabling 3.0 Menu Support If you have WordPress 3.0 installed, but your theme is older and doesn’t support it, here’s how to make those fancy awesome new menus work in your theme… First, sign into the admin. This is located at www.yoursitehere.com/wp-admin Next, click on the Appearance Section. Click Editor Click Theme Functions (functions.php) on [...]
The HTML helper is pretty useful, here’s how you write a link in a view file: <?php echo $html->link(’click me’, array( ‘controller’=>’users’, ‘action’=>’index’ ) ); ?> The parameters in this are: title (what you actually click on) link location array(controller, action, id (if needed for edit)) (optional) attributes array
If you want to perform a sum or count on the records in a DataTable, you can, very simply. You’ll have to have a DataTable with something in it, like results from a database, then you do this: // my DataTable is full of customer data and is named "dt" object newCustomerCount = dt.Compute("count(id)","CustomerID > [...]
July 16 2010 by
Ryan Carter in
MySQL |
To hand-code a table, or create a bunch of tables in a script, use this: CREATE TABLE `tablename`( `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL ) You may note the “backticks” which are the little symbol on the same key as the tilde “~”, and are used to note the tablename [...]
July 16 2010 by
Ryan Carter in
SQL |
There is no pause in there, “LIKE!…searches!” This is a no teeny-bopper zone (unless you want to program stuff, then by all means)! When you know only part of what you’re looking for in a SQL SELECT statement, especially for AJAX auto-complete queries, you will need to employ the all-consuming power of the “LIKE Search” [...]