- 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
<% @sections.each do |section| %> | |
<h2><%= section_name(section) %></h2> | |
<% section.topics.each do |topic| %> | |
<%= topic.name %><br> | |
<% 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 donate | |
@heroPage = HeroPage.search_url(params[:url], DateTime.now) | |
unless @heroPage | |
redirect_to :action=>"the_unknown_hero" | |
return | |
else | |
@donation = Donation.new() | |
# if @donation.save? then session[:mydonation_id] = @donation.id 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 |
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 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
# 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
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
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
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 |
OlderNewer