Welcome To Snipplr


Everyone's Recent Rails Snippets



0 728 posted 14 years ago by inkdeep
0 565 posted 14 years ago by nflamel
Create config/initializers/paperclip.rb
0 760 posted 14 years ago by Nek
0 745 posted 14 years ago by almazom
This lets you type Mandarin tones like a1, o2, e3, and so on instead of having to type the real pinyin. The tones are saved with the proper characters in the database.
0 849 posted 14 years ago by 67ideas
Put the height_options method into a helper file, and use it as the select collection for select or collection_select. It allows heights between 4 feet and 7 feet. To change these limits, change 48 and 84 to some other numbers.
0 710 posted 14 years ago by 67ideas
This is the code I use when I want to test a helper. It uses Factory Girl and Shoulda, but they're not needed to make it work.
0 881 posted 14 years ago by nflamel
I used to directly inject javascript and CSS into my HEAD elements just like you see in all of the tutorials online and in books. Recently I decided to try a different approach, and I feel this is more in keeping with the ruby and rails "declaration"...
0 980 posted 14 years ago by sgtrock
I used to directly inject javascript and CSS into my HEAD elements just like you see in all of the tutorials online and in books. Recently I decided to try a different approach, and I feel this is more in keeping with the ruby and rails "declaration"...
0 952 posted 14 years ago by sgtrock
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 702 posted 14 years ago by sgtrock
Regular menu item adding current class if current url equal menu item destination.
1 945 posted 14 years ago by smoothdzion
I needed to make menu items that kept the current class based on the controller being accessed.
1 723 posted 14 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 776 posted 14 years ago by smoothdzion
0 590 posted 14 years ago by obi
0 622 posted 14 years ago by jommy
The code to find all objects from a model and use them as select options.
1 935 posted 15 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 700 posted 15 years ago by smoothdzion
Used to create checkboxes to select multiple categories for a post or any other type of applicable situation.
1 668 posted 15 years ago by smoothdzion
requires Rails libraries. could be rewritten to just use core Ruby libs, but I'm too lazy right now and I use this entirely in my Rails apps.
0 901 posted 15 years ago by mepatterson
This could be further abstracted to work with other db's. Also, it really should be using Ruby's Tempfile class instead of assuming the local machine is *NIX based, but it works :)
0 825 posted 15 years ago by nate63179
In this instance, used as an after-deploy hook to create a symlink to a shared db config file
0 833 posted 15 years ago by nate63179