Welcome To Snipplr
Everyone's Recent Ruby Snippets Tagged ruby
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
validate :price_must_be_at_least_a_cent
protected def price_must_be_at_least_a_cent
errors.add(:price, 'should be at least 0.01') if price.nil? || price < 0.01
end
0
411
posted 13 years ago by stayce
Credit: http://pragmatig.wordpress.com/2009/04/14/recursive-symbolize_keys/
0
410
posted 13 years ago by nate63179
Fetches an RSS feed and displays the title and summary of each entry. Nothing fancy.
0
416
posted 13 years ago by PhilK
Simple example for using ActionMailer with Gmail (or other hosts if you remove the TLS settings).
0
443
posted 13 years ago by PhilK
Ruby provides a platform independent way of displaying file paths. Here are a few common ways to show absolute and relative paths.
0
490
posted 13 years ago by chrisaiv
This shows how we can find objects inside code blocks (aka data sets).
0
690
posted 13 years ago by chrisaiv
Inserted at the top of the method body, this line creates instance variables for each of the method parameters and sets them to their respective argument values.
0
529
posted 13 years ago by pmadden
The shell command which provides documentation for Ruby's classes and methods is:
0
409
posted 13 years ago by deepsoul