Posted on Jun 29th, 2006 in
Quick Tips,
Ruby on Rails |
2 comments
The Typo theme ‘Lucid’ seems to generate an error when used with the latest version (trunk) of Typo. In order to solve this, simply replace the following code in your /typo/themes/lucid/layouts/default.rhtml file:
<%= render_component(:controller => 'sidebars/sidebar',
:action => 'display_plugins') %>
with
<% benchmark "BENCHMARK: layout/sidebars" do %>
<%=...
Posted on Feb 5th, 2006 in
Mathematics,
Quick Tips |
3 comments
INPUT: a string containing decimal numbers.
OUTPUT: an array containing all the decimal numbers within the given string.
You can accomplish this task very quickly with the String#scan method and the right Regular Expression (regex).
Given a string s, you can use:
numbers = s.scan /[-+]?\d*\.?\d+/
numbers will be an array whose elements are the decimal numbers within the string s. Note how the regex considers the...
Posted on Jan 11th, 2006 in
Quick Tips,
Ruby on Rails |
1 comment
Sometimes you may want to exclude an action from being processed with the controller’s layout. In other words, you may need to use a default layout for all the methods in the controller, except for one of them.
A quick way to do this is:
class MyController < ApplicationController
layout "mycontroller", :except =>...