Welcome To Snipplr
Everyone's Recent Rails Snippets Tagged ruby
- All /
 - JavaScript /
 - HTML /
 - PHP /
 - CSS /
 - Ruby /
 - Objective C
 
A very concise ruby on rails helper method that converts seconds into human readable format.  It will not display any time periods that have 0 (ie: 1 hour 13 seconds - skipping minutes as there were none)  Due to complexity, months were not factored...
        
        
        
            0 
        
        
            2511 
        
                    posted 11 years ago by uberdragon
            Supported brands
    
    name             | key
    -----------------------
    American Express | :amex
    China UnionPay   | :unionpay
    Diners Club      | :diners
    Dinner Club US   | :diners_us
    Discover         | :discover...
        
        
        
            0 
        
        
            4489 
        
                    posted 12 years ago by Fivell
            Working on the problem described here: http://forums.att.com/t5/Data-Messaging-Features-Internet/3G-proxy-wnsnet-attws-com-strips-HTTP-response-headers/m-p/3294533/highlight/false#M59737
After some testing we found the below code to fix our troubl...
        
        
        
            0 
        
        
            3434 
        
                    posted 12 years ago by mightybs
            Esto suele ocurrer muy amenudo cuando instalamos Ruby on Rails antes que MySQL. Es un error "Library not loaded: libmysqlclient.18.dylib (LoadError)" donde lista los directorios donde busca y no lo encuentra. La solución es guiarle para que lo encue...
        
        
        
            0 
        
        
            3299 
        
                    posted 13 years ago by skozz
            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 
        
        
            1133 
        
                    posted 15 years ago by sgtrock
            Regular menu item adding current class if current url equal menu item destination.
        
        
        
            1 
        
        
            1419 
        
                    posted 15 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 
        
        
            1208 
        
                    posted 15 years ago by smoothdzion
            The code to find all objects from a model and use them as select options.
        
        
        
            1 
        
        
            1431 
        
                    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 
        
        
            1095 
        
                    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 
        
        
            1048 
        
                    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 
        
        
            1459 
        
                    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 
        
        
            1255 
        
                    posted 16 years ago by nate63179
            In this instance, used as an after-deploy hook to create a symlink to a shared db config file
        
        
        
            0 
        
        
            1347 
        
                    posted 16 years ago by nate63179
            Put the following in your controller to define the content-type for *that* specific controller.
        
        
        
            0 
        
        
            1000 
        
                    posted 16 years ago by chrisamini
            Can be used to generate a random code for an online voucher. You just need to set VOUCHER_CODE_LENGTH in your environment.rb or similar.
        
        
        
            1 
        
        
            1289 
        
                    posted 16 years ago by jordanbrock