Welcome To Snipplr
Everyone's Recent Rails Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
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
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
Rails
will_paginate with jquery ajax / поÑтаничный вывод в Rails Ñ will_paginate и Jquery
0
1091
posted 15 years ago by almazom
Rails
olark service using with rails and haml / иÑпользование Olark ÑервиÑа Ñ Rails и Haml
0
918
posted 15 years ago by almazom