Skip to content

Instantly share code, notes, and snippets.

@ridget
ridget / CDbCommand.php
Created June 20, 2012 01:05
Adding an addPrimaryKey command to yii's db migrations -- supports composite primary keys
/**
* Builds a SQL statement for creating a primary key constraint.
* @param string $name the name of the primary key to be created. The name will be properly quoted by the method.
* @param string $table the table who will be inheriting the primary key. The name will be properly quoted by the method.
* @param string $column the column where the primary key will be effected. The name will be properly quoted by the method.
* @return integer number of rows affected by the execution.
* @since 1.1.6
*/
public function addPrimaryKey($name,$table,$columns)
{
@ridget
ridget / keyword module
Created April 15, 2012 06:12
testing for keywords
module Keywords
MAX_KEYWORDS = 8
def keywords_to_array(keywords)
@keywords = keywords
end
def assign_values(keywords)
keyword_values = Hash.new
MAX_KEYWORDS.downto(1){ |value, init=8|
keyword_assigned = keywords[init-value]
@ridget
ridget / right.md
Created February 7, 2012 10:56 — forked from radar/rules.md

Asking questions, the right way

When asking questions in the #rubyonrails channel, please follow these 10 simple rules:

  1. Do your research before hand. Your question may be answerable with a quick Google search.
  2. If you've tried Googling, explain what terms you've tried to use so people can better help you.
  3. Do not use pastebin.org or bin.cakephp.org (LOL!). Its font is tiny and it has ads on it which cause the page to load slowly. Use Gist (http://gist.github.com) instead!
  4. Remember that using English is preferable, as the majority of people in the channel speak it. Asking in other languages may give you a response, but English is best.
  5. Anything more than 2 lines goes in a Gist (http://gist.github.com) or a Pastie (http://pastie.org). Spamming the channel with walls of text is not welcome.
  6. Clearly explain what is happening and create a Gist (http://gist.github.com) or Pastie (http://pastie.org) of the code that is causing the problem you are encountering, as wel