- no fucking semi-colons (unless you really want them)
- irb
- local variable definition
- +, *, /, - are all methods
- puts vs print
- multiplying strings
- using if & when
- defining a method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
if @baby.update_attributes(params[:baby]) | |
if params[:notify] == true | |
flash[:notice] = "Done" | |
else | |
redirect_to(root_url(:host => with_subdomain(@baby.subdomain)), :notice => 'Your baby was successfully updated and everyone has been told the good news.') | |
end | |
else | |
render :action => "edit" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
include Mongoid::Document | |
field :email | |
validates_format_of :email, :with => /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i, :message => "is not a valid email adress." | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Article < ActiveRecord::Base | |
# Has attributes: :title, :body, :active | |
attr_protected :active | |
end | |
class Image < ActiveRecord::Base | |
# Has attributes: :title, :filename, :active | |
attr_accessible :title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grey='\e[0;90m' | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$grey%}(" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$grey%}) %{$fg[yellow]%}✗%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$grey%})" | |
function pat_prompt { | |
(( spare_width = ${COLUMNS} )) | |
prompt=" " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What did you do to get good at Rails? | |
Who taught you what you know? | |
Do you have any fond (or not so fond) memories of your learning experiences? | |
What was your first production app and what did you learn from it? | |
What tools do you use to make your life easier? | |
What did you find particularly hard to grok when learning Rails? | |
When did you start on Rails? | |
Did you learn Ruby first or try to jump straight into Rails? | |
Did you read any books to get good at Rails? | |
What system do you use? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# named_scope :between, lambda {|start_date, end_date, field| | |
# { :conditions => ["\"#{field}\" >= ? AND \"#{field}\" <= ?", start_date, end_date] } | |
# } | |
From the docs... | |
A range may be used in the hash to use the SQL BETWEEN operator | |
Student.find(:all, :conditions => { :grade => 9..12 }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def v1(value) | |
value || "-" | |
end | |
def v2(object, method) | |
object && value = object.send(method) ? value : "-" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.retrieve_capture_fields(the_page, type_of_capture) | |
case the_page | |
when Event then retrieve_capture_data(type_of_capture, the_event_or_hero_page) | |
when HeroPage then | |
if the_event_or_hero_page.is_this_hero_page_associated_with_an_event && the_page.event | |
retrieve_capture_data(type_of_capture, the_page.event) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.determine_if_this_is_an_event_or_hero_page_mode(args) | |
if args[:event_url] | |
"event" | |
elsif args[:url] | |
"hero_page" | |
end | |
end |
NewerOlder