Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

2 total

doctype for standard layout

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
  <head> 
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
  <title>Events: <%= controller.action_name %></title> 
  <%= stylesheet_link_tag 'style' %> 
</head> 
<body> 

  <p style="color: green"><%= flash[:notice] %></p> 
  <%= yield %> 
</body> 
</html> 

find conditions via hash

Instead of simply adding a list of things at the end of the array, you can also pass in a hash and change the question marks to actual named replacements. This can help you keep the order of your arguments straight.

Event.find(
  :all,
  :conditions => [ "title like :search or description like :search",
                   {:search => "%Tiki%"}]
)
2 total