Welcome To Snipplr


Everyone's Recent Snippets Tagged ruby



1 2 3 4 5 6 ... 13
0 3546 posted 16 years ago by almazom
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 1445 posted 16 years ago by stayce
Because different systems put it in different places.
0 1347 posted 16 years ago by alvarezrilla
0 1469 posted 16 years ago by inkdeep
0 1541 posted 16 years ago by inkdeep
0 2022 posted 16 years ago by inkdeep
0 1278 posted 16 years ago by inkdeep
0 1642 posted 16 years ago by inkdeep
0 1476 posted 16 years ago by sukantahazra
0 1411 posted 16 years ago by nflamel
0 1446 posted 16 years ago by sai-venkat
0 1305 posted 16 years ago by kerpunk
Credit: http://pragmatig.wordpress.com/2009/04/14/recursive-symbolize_keys/
0 1529 posted 16 years ago by nate63179
I never can remember the exact name of the exception to call in self.down for a migration that cannot be undone. So I decided to come up with something easier to remember. This feels more "ruby-ish" and "rails-ish" to me, and so far it works just fin...
0 1519 posted 16 years ago by sgtrock
Regular menu item adding current class if current url equal menu item destination.
1 1826 posted 16 years ago by smoothdzion
I needed to copy the value of one field to a couple of others in case users decided to forget to fill them out. Using jQuery and added it to a helper because I was using in multiple places. Created variables to make it more readable.
1 1622 posted 16 years ago by smoothdzion
0 1288 posted 16 years ago by jommy
0 1145 posted 16 years ago by bigredjoe
Fetches an RSS feed and displays the title and summary of each entry. Nothing fancy.
0 1411 posted 16 years ago by PhilK
Simple example for using ActionMailer with Gmail (or other hosts if you remove the TLS settings).
0 1497 posted 16 years ago by PhilK
The code to find all objects from a model and use them as select options.
1 1865 posted 16 years ago by smoothdzion
For separating a list of categories with a comma that are linked. There may be a better way. Leave a comment if you have a better way. This was the first way I found that worked. This code increments the count 1 at a time. It applies the incre...
1 1486 posted 16 years ago by smoothdzion
Used to create checkboxes to select multiple categories for a post or any other type of applicable situation.
1 1465 posted 16 years ago by smoothdzion
0 1290 posted 16 years ago by kerpunk
Don't forget to use require 'directory/name_of_class'
0 2333 posted 16 years ago by chrisaiv
1 1956 posted 16 years ago by endorfin
1 2 3 4 5 6 ... 13